UNPKG

756 BJavaScriptView Raw
1class appFactory {
2 constructor() {
3 this.apps = {}
4 }
5
6 registerApp = (name, app) => {
7 if (this.apps[name])
8 throw `已经注册过这个app,不能重复注册. name: ${name}`
9
10 this.apps[name] = app
11 }
12
13 registerApps = (apps) => {
14 this.apps = {
15 ...this.apps,
16 ...apps
17 }
18
19 //window.__mk_apps__ = this.apps
20 }
21
22 getApp = (name) => {
23 var app = this.apps[name]
24
25 if (!app) {
26 throw `没有注册这个app. name: ${name}`
27 }
28 return app
29 }
30
31 getApps = () => {
32 return this.apps
33 }
34
35}
36
37const appFactoryInstance = new appFactory()
38
39export default appFactoryInstance
\No newline at end of file