12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
-
-
-
-
-
-
-
-
- function mitt(all ) {
- all = all || Object.create(null);
- return {
-
- on: function on(type , handler ) {
- (all[type] || (all[type] = [])).push(handler);
- },
-
- off: function off(type , handler ) {
- if (all[type]) {
- all[type].splice(all[type].indexOf(handler) >>> 0, 1);
- }
- },
-
- emit: function emit(type , evt ) {
- (all[type] || []).slice().map(function (handler) { handler(evt); });
- (all['*'] || []).slice().map(function (handler) { handler(type, evt); });
- }
- };
- }
- export default mitt;
|