|
@@ -0,0 +1,24 @@
|
|
|
+import mitt from 'mitt'
|
|
|
+
|
|
|
+const emitter = mitt()
|
|
|
+
|
|
|
+// // 绑定/监听事件
|
|
|
+// emitter.on('foo', e => console.log('foo', e) )
|
|
|
+
|
|
|
+// // 绑定/监听全部事件
|
|
|
+// emitter.on('*', (type, e) => console.log(type, e) )
|
|
|
+
|
|
|
+// // 触发事件
|
|
|
+// emitter.emit('foo', { a: 'b' })
|
|
|
+
|
|
|
+// // 清除全部
|
|
|
+// emitter.all.clear()
|
|
|
+
|
|
|
+// // 清除单个事件
|
|
|
+// emitter.off('foo', e => console.log('foo', e) )
|
|
|
+// // working with handler references:
|
|
|
+// function onFoo() {}
|
|
|
+// emitter.on('foo', onFoo) // listen
|
|
|
+// emitter.off('foo', onFoo) // unlisten
|
|
|
+
|
|
|
+export default emitter;
|