提交 9489b9cc 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

refactor(getApp): 移除 eventBus

上级 ed8e1549
...@@ -47,10 +47,6 @@ describe('getApp', () => { ...@@ -47,10 +47,6 @@ describe('getApp', () => {
expect(newLifeCycleNum - oldLifeCycleNum).toBe(100) expect(newLifeCycleNum - oldLifeCycleNum).toBe(100)
await page.callMethod('setLifeCycleNum', oldLifeCycleNum) await page.callMethod('setLifeCycleNum', oldLifeCycleNum)
}) })
it('eventBus', async () => {
const res = await page.callMethod('checkEventBus')
expect(res).toBe(true)
})
it('getAndroidApplication', async () => { it('getAndroidApplication', async () => {
const res = await page.callMethod('checkGetAndroidApplication') const res = await page.callMethod('checkGetAndroidApplication')
expect(res).toBe(true) expect(res).toBe(true)
......
...@@ -39,9 +39,6 @@ ...@@ -39,9 +39,6 @@
increase lifeCycleNum increase lifeCycleNum
</button> </button>
<text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text> <text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
<button class="uni-common-mt" @click="checkEventBus">
check eventBus
</button>
<button class="uni-common-mt" @click="checkGetAndroidApplication"> <button class="uni-common-mt" @click="checkGetAndroidApplication">
check getAndroidApplication check getAndroidApplication
</button> </button>
...@@ -174,39 +171,6 @@ ...@@ -174,39 +171,6 @@
setLifeCycleNum(num : number) { setLifeCycleNum(num : number) {
setLifeCycleNum(num) setLifeCycleNum(num)
}, },
checkEventBus() : boolean {
const app = getApp()
let num = 0
const fn1 = (args : any | null) => {
console.log('fn1 triggred', args)
num++
}
const fn2 = (args : any | null) => {
console.log('fn2 triggred', args)
num++
}
const fn3 = (args : any | null) => {
console.log('fn3 triggred', args)
num++
}
app.on('fn12', fn1)
app.on('fn12', fn2)
app.once('fn3', fn3)
app.emit('fn12', { name: 'name' })
app.emit('fn12', { age: 20 })
app.off('fn12', fn1)
app.emit('fn12', null)
app.emit('fn3', { name: 'name' })
app.emit('fn3', { age: 20 })
app.emit('fn3', null)
const res = num == 6
console.log('check eventBus', res)
return res
},
checkGetAndroidApplication() : boolean { checkGetAndroidApplication() : boolean {
const app = getApp() const app = getApp()
const androidApplication = app.getAndroidApplication() const androidApplication = app.getAndroidApplication()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册