@zeppos/zeus-cli 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/post-command.js +1 -1
- package/package.json +2 -2
- package/private-modules/zeppos-app-utils/dist/config/project.js +1 -1
- package/private-modules/zeppos-app-utils/dist/modules/fetchDevices.js +3 -1
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/.prettierrc.js +6 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/app-side/index.js +45 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/app.js +25 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/app.json +64 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/assets/gts/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/page/home/index.page.js +155 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/page/home/index.page.json +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/page/home/index.style.js +92 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/page/i18n/en-US.po +9 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/secondary-widget/index.js +160 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/setting/i18n/en-US.po +5 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/setting/index.js +143 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/data.js +67 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/defer.js +35 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/device-polyfill.js +6 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/es6-promise.js +1178 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/event.js +42 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/message-side.js +1190 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/message.js +1196 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/utils/constants.js +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/utils/index.js +38 -0
- package/private-modules/zeppos-app-utils/package.json +1 -1
package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/todo-list/shared/event.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export class EventBus {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.map = new Map()
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
on(type, cb) {
|
|
7
|
+
if (this.map.has(type)) {
|
|
8
|
+
this.map.get(type).push(cb)
|
|
9
|
+
} else {
|
|
10
|
+
this.map.set(type, [cb])
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
off(type, cb) {
|
|
15
|
+
if (type) {
|
|
16
|
+
if (cb) {
|
|
17
|
+
const cbs = this.map.get(type)
|
|
18
|
+
|
|
19
|
+
if (!cbs) return
|
|
20
|
+
const index = cbs.findIndex((i) => i === cb)
|
|
21
|
+
|
|
22
|
+
if (index >= 0) {
|
|
23
|
+
cbs.splice(index, 1)
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
this.map.delete(type)
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
this.map.clear()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
emit(type, ...args) {
|
|
34
|
+
for (let cb of this.map.get(type) ? this.map.get(type) : []) {
|
|
35
|
+
cb && cb(...args)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
count(type) {
|
|
40
|
+
return this.map.get(type) ? this.map.get(type).length : 0
|
|
41
|
+
}
|
|
42
|
+
}
|