jfactory
1.0.0
Modularisieren Sie Ihre Anwendung einfach in stornierbare Komponenten.
Alles, was sie initialisieren, kann automatisch überwacht, gestoppt und entfernt werden.
einschließlich Ansichten, verschachtelten Versprechen, Anfragen, Zuhörern, DOM und CSS.
install , enable , disable und uninstall .await install und await enable , alles parallel zu Aufgaben.uninstall Reverts install , disable enable .| Installation | Dokumentation |
|---|---|
npm add jfactory | Merkmale / Klassen |
Komponenten können von jeder Klasse oder einfacher erweitert werden, indem ein Objektliteral über die Verknüpfung jFactory() verwendet werden:
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 ( ) ;