README
WxEventHandler
Make you feel like use Vue's event controler, just support in single page init your single instance.
example code
const WxEventHandler = require('wx-event-handler').default;
//实例化一个事件控制器
const myEventHandler = new WxEventHandler("MyPageName");
Page({
sayHello(hello, name){
wx.showModal({
title: hello,
content:name
});
},
onLoad(){
//监听
myEventHandler.on("sayHelloTo", this.sayHelloTo);
},
onUnload(){
//取消监听
myEventHandler.off("sayHelloTo");
},
onClick(){
//发射事件
myEventHandler.emit("sayHelloTo", "Hello", "Peter Yuan");
}
}