javascript事件驱动中间件
<button type="button" id="btn1" class="btn btn-primary" style="width:100px;text-align:center;margin:auto;">Start</button>
var mw = new EventMiddleware($("#btn1"));
调用next(context)执行下一个中间件, return则终止中间件执行
mw.one((next) => (context) => { console.log("第一个执行"); next(context) })
.useStart((next) => (context) => { console.log("只执一次1"); next(context) })
.useStart((next) => (context) => { console.log("只执一次2"); next(context) })
mw.useEvent((next) => (context) => { context.click(() => { console.log("执行" + ++i + "次点击事件"); next(context) }) })
mw.use((next) => (context) => { console.log("触发中间件1"); next(context) })
.use((next) => (context) => { console.log("触发中间件2"); next(context) })
mw.end((next) => (context) => { })
mw.run()