jfactory
1.0.0
응용 프로그램을 취소 가능한 구성 요소로 쉽게 모듈화하십시오.
초기화 된 모든 것을 모니터링, 중지 및 자동으로 제거 할 수 있습니다.
견해, 중첩 약속, 요청, 청취자, DOM 및 CSS 포함.
install , enable , disable 및 기능 uninstall 제공합니다.await install 중인 구독을 자동으로 기다리고 있습니다 await enableinstall uninstall disable 반전 enable .| 설치 | 선적 서류 비치 |
|---|---|
npm add jfactory | 특성 / 수업 |
단축키 jFactory() 를 통해 객체를 사용하여 구성 요소를 모든 클래스에서 또는 더 이상 확장 할 수 있습니다 .
let component = jFactory ( "myComponent" , {
async onInstall ( ) {
this . $domFetch ( "myDom" , "asset.html" , "body" ) ;
this . $cssFetch ( "myCss" , "asset.css" ) ;
} ,
async onEnable ( ) {
this . $interval ( "myUpdater" , 1000 , ( ) =>
this . $fetchJSON ( "myRequest" , "asset.json" )
. then ( data => this . $log ( "updated" , data ) )
) ;
this . $on ( "click" , "#bt-switch" , ( ) => this . mySwitchHandler ( ) ) ;
this . $on ( "click" , "#bt-close" , ( ) => this . myCloseHandler ( ) ) ;
} ,
async mySwitchHandler ( ) {
await ( this . $ . states . enabled ? this . $disable ( ) : this . $enable ( ) ) ;
this . $log ( this . $ . states . enabled ) ;
} ,
async myCloseHandler ( ) {
// Called by the click event on #bt-close
// Everything in the component registery is automatically stoped and removed:
// (myDom, myCss, myUpdater, myRequest, DOM events)
// Residual callbacks not manually stopped from
// the onDisable() and onUninstall() handlers will be ignored.
await this . $uninstall ( ) ;
}
} )
await component . $install ( ) ;
await component . $enable ( ) ;