hy-event-store
hy-event-store copied to clipboard
An event-based global state management tool for vue, react, mini-program, ect.
事件总线event三个方法:on,once,off分别用于什么场景? 我在微信小程序中使用,想在切换组件是发送事件,切换可以不生效。 但是: 使用on时,在切换组件会触发多次,会有错误数据; 使用once时,在切换不生效的情况下,无法发送第二次; 使用off时,报错 Cannot read property 'length' of undefined;
``` let obj = { funcTest: (...args) => { return new Promise((resolve, reject) => { resolve('event') }) }, }; const dispatch = (actionName, ...args) => { const actionFn = obj[actionName];...
clear() { this.emitBus = {} } hasEvent(eventName) { return Object.keys(this.emitBus).includes(eventName) }
希望能在wxml页面中通过bindtap=“事件名称”的方式绑定全局事件,比如全局跳转。
在dispatch的时候使用await无法获取到返回值,看了源码在dispatch方法中本身没有return任何值,此处返回一下结果就可以拿到,但不确定是否对整个包会不会产生影响.附图:
安装1.1.0版本,npm install [email protected]
在微信小程序中,需要单独绑定this,内部没有处理