microfront
A JavaScript library for building "micro frontends".
How to use
You can also use es6
api
create(html: stirng, dom: HTMLElement)
Create a "micro app" which will load html and js just like an iframe but is not a real iframe,and return an object with the following methods:
"html" can contain script, style, link and other html tags
;
-
unmount() Unmount the app
-
on(name: string, cb: any)
Built in two events: "mount" and "unmount" mount: when all html scripts are loaded unmount: when calling the app's unmount method
app;
-
emit(name: string, value: any)
Emit event
appapp;
-
effectPromiseFunction(fn: any)
Let the function returns promise be processed according to the app state, if the app has been unmounted, the promise will be rejected.
var customFetch = ;
-
effectCallbackFunction(fn: any)
Let the callback function be processed according to the app state, if the app has been unmounted, the callback method will not be called.
var customSetTimeout = ; ;
Development
$ yarn
$ yarn dev
$ open http://localhost:5000/examples/example1/