eventdispatcher
Advanced tools
Comparing version 1.5.0 to 1.5.1
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.EventDispatcher = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:true});function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function')}}function isEmpty(obj){for(var prop in obj){if(obj.hasOwnProperty(prop)){return false}}return true}var _instanceMap={};var EventDispatcher=function(){function EventDispatcher(){_classCallCheck(this,EventDispatcher);this._eventMap={};this._destroyed=false;this.on=this.bind=this.addEventListener=this.addListener;this.off=this.unbind=this.removeEventListener=this.removeListener;this.once=this.one=this.addListenerOnce;this.emmit=this.trigger=this.dispatchEvent=this.dispatch}EventDispatcher.getInstance=function getInstance(key){if(!key){throw new Error('key must be')}return _instanceMap[key]||(_instanceMap[key]=new EventDispatcher)};EventDispatcher.prototype.addListener=function addListener(event,listener){var listeners=this.getListener(event);if(!listeners){this._eventMap[event]=[listener]}else if(listeners.indexOf(listener)===-1){listeners.push(listener)}return this};EventDispatcher.prototype.addListenerOnce=function addListenerOnce(event,listener){var _this=this,_arguments=arguments;var s=this;var f2=function f2(){s.removeListener(event,f2);return listener.apply(_this,_arguments)};return this.addListener(event,f2)};EventDispatcher.prototype.removeListener=function removeListener(event,listener){if(typeof listener==='undefined'){return this.removeAllListener(event)}var listeners=this.getListener(event);if(listeners){var i=listeners.indexOf(listener);if(i>-1){listeners=listeners.splice(i,1);if(!listeners.length){delete this._eventMap[event]}}}return this};EventDispatcher.prototype.removeAllListener=function removeAllListener(event){var listeners=this.getListener(event);if(listeners){this._eventMap[event].length=0;delete this._eventMap[event]}return this};EventDispatcher.prototype.hasListener=function hasListener(event){return this.getListener(event)!==null};EventDispatcher.prototype.hasListeners=function hasListeners(){return this._eventMap!==null&&this._eventMap!==undefined&&!isEmpty(this._eventMap)};EventDispatcher.prototype.dispatch=function dispatch(eventType,eventObject){var listeners=this.getListener(eventType);if(listeners){eventObject=eventObject||{};eventObject.type=eventType;eventObject.target=eventObject.target||this;var i=-1;while(++i<listeners.length){listeners[i](eventObject)}}return this};EventDispatcher.prototype.getListener=function getListener(event){var result=this._eventMap?this._eventMap[event]:null;return result||null};EventDispatcher.prototype.destroy=function destroy(){if(this._eventMap){for(var i in this._eventMap){this.removeAllListener(i)}this._eventMap=null}this._destroyed=true;return this};return EventDispatcher}();exports.default=EventDispatcher;module.exports=exports['default']; | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:true});function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function')}}function isEmpty(obj){for(var prop in obj){if(obj.hasOwnProperty(prop)){return false}}return true}var _instanceMap={};var EventDispatcher=function(){function EventDispatcher(){_classCallCheck(this,EventDispatcher);this._eventMap={};this._destroyed=false;this.on=this.bind=this.addEventListener=this.addListener;this.off=this.unbind=this.removeEventListener=this.removeListener;this.once=this.one=this.addListenerOnce;this.emit=this.trigger=this.dispatchEvent=this.dispatch}EventDispatcher.getInstance=function getInstance(key){if(!key){throw new Error('key must be')}return _instanceMap[key]||(_instanceMap[key]=new EventDispatcher)};EventDispatcher.prototype.addListener=function addListener(event,listener){var listeners=this.getListener(event);if(!listeners){this._eventMap[event]=[listener]}else if(listeners.indexOf(listener)===-1){listeners.push(listener)}return this};EventDispatcher.prototype.addListenerOnce=function addListenerOnce(event,listener){var _this=this;var _f=function f2(e){listener(e);_this.off(event,_f);listener=null;_f=null};return this.on(event,_f)};EventDispatcher.prototype.removeListener=function removeListener(event,listener){if(!listener){return this.removeAllListener(event)}var listeners=this.getListener(event);if(listeners){var i=listeners.indexOf(listener);if(i>-1){listeners=listeners.splice(i,1);if(!listeners.length){delete this._eventMap[event]}}}return this};EventDispatcher.prototype.removeAllListener=function removeAllListener(event){var listeners=this.getListener(event);if(listeners){this._eventMap[event].length=0;delete this._eventMap[event]}return this};EventDispatcher.prototype.hasListener=function hasListener(event){return this.getListener(event)!==null};EventDispatcher.prototype.hasListeners=function hasListeners(){return this._eventMap!==null&&this._eventMap!==undefined&&!isEmpty(this._eventMap)};EventDispatcher.prototype.dispatch=function dispatch(eventType,eventObject){var listeners=this.getListener(eventType);if(listeners){eventObject=eventObject||{};eventObject.type=eventType;eventObject.target=eventObject.target||this;var i=-1;while(++i<listeners.length){listeners[i](eventObject)}}return this};EventDispatcher.prototype.getListener=function getListener(event){var result=this._eventMap?this._eventMap[event]:null;return result||null};EventDispatcher.prototype.destroy=function destroy(){if(this._eventMap){for(var i in this._eventMap){this.removeAllListener(i)}this._eventMap=null}this._destroyed=true;return this};return EventDispatcher}();exports.default=EventDispatcher;module.exports=exports['default']; | ||
},{}]},{},[1])(1) | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.EventDispatcher=e()}}(function(){return function e(t,n,r){function i(o,u){if(!n[o]){if(!t[o]){var f="function"==typeof require&&require;if(!u&&f)return f(o,!0);if(s)return s(o,!0);var a=new Error("Cannot find module '"+o+"'");throw a.code="MODULE_NOT_FOUND",a}var h=n[o]={exports:{}};t[o][0].call(h.exports,function(e){var n=t[o][1][e];return i(n?n:e)},h,h.exports,e,t,n,r)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}Object.defineProperty(n,"__esModule",{value:!0});var s={},o=function(){function e(){r(this,e),this._eventMap={},this._destroyed=!1,this.on=this.bind=this.addEventListener=this.addListener,this.off=this.unbind=this.removeEventListener=this.removeListener,this.once=this.one=this.addListenerOnce,this.emmit=this.trigger=this.dispatchEvent=this.dispatch}return e.getInstance=function(t){if(!t)throw new Error("key must be");return s[t]||(s[t]=new e)},e.prototype.addListener=function(e,t){var n=this.getListener(e);return n?-1===n.indexOf(t)&&n.push(t):this._eventMap[e]=[t],this},e.prototype.addListenerOnce=function(e,t){var n=this,r=arguments,i=this,s=function o(){return i.removeListener(e,o),t.apply(n,r)};return this.addListener(e,s)},e.prototype.removeListener=function(e,t){if("undefined"==typeof t)return this.removeAllListener(e);var n=this.getListener(e);if(n){var r=n.indexOf(t);r>-1&&(n=n.splice(r,1),n.length||delete this._eventMap[e])}return this},e.prototype.removeAllListener=function(e){var t=this.getListener(e);return t&&(this._eventMap[e].length=0,delete this._eventMap[e]),this},e.prototype.hasListener=function(e){return null!==this.getListener(e)},e.prototype.hasListeners=function(){return null!==this._eventMap&&void 0!==this._eventMap&&!i(this._eventMap)},e.prototype.dispatch=function(e,t){var n=this.getListener(e);if(n){t=t||{},t.type=e,t.target=t.target||this;for(var r=-1;++r<n.length;)n[r](t)}return this},e.prototype.getListener=function(e){var t=this._eventMap?this._eventMap[e]:null;return t||null},e.prototype.destroy=function(){if(this._eventMap){for(var e in this._eventMap)this.removeAllListener(e);this._eventMap=null}return this._destroyed=!0,this},e}();n["default"]=o,t.exports=n["default"]},{}]},{},[1])(1)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.EventDispatcher=e()}}(function(){return function e(t,n,i){function r(s,u){if(!n[s]){if(!t[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var a=n[s]={exports:{}};t[s][0].call(a.exports,function(e){var n=t[s][1][e];return r(n?n:e)},a,a.exports,e,t,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)r(i[s]);return r}({1:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}Object.defineProperty(n,"__esModule",{value:!0});var o={},s=function(){function e(){i(this,e),this._eventMap={},this._destroyed=!1,this.on=this.bind=this.addEventListener=this.addListener,this.off=this.unbind=this.removeEventListener=this.removeListener,this.once=this.one=this.addListenerOnce,this.emit=this.trigger=this.dispatchEvent=this.dispatch}return e.getInstance=function(t){if(!t)throw new Error("key must be");return o[t]||(o[t]=new e)},e.prototype.addListener=function(e,t){var n=this.getListener(e);return n?-1===n.indexOf(t)&&n.push(t):this._eventMap[e]=[t],this},e.prototype.addListenerOnce=function(e,t){var n=this,i=function(r){t(r),n.off(e,i),t=null,i=null};return this.on(e,i)},e.prototype.removeListener=function(e,t){if(!t)return this.removeAllListener(e);var n=this.getListener(e);if(n){var i=n.indexOf(t);i>-1&&(n=n.splice(i,1),n.length||delete this._eventMap[e])}return this},e.prototype.removeAllListener=function(e){var t=this.getListener(e);return t&&(this._eventMap[e].length=0,delete this._eventMap[e]),this},e.prototype.hasListener=function(e){return null!==this.getListener(e)},e.prototype.hasListeners=function(){return null!==this._eventMap&&void 0!==this._eventMap&&!r(this._eventMap)},e.prototype.dispatch=function(e,t){var n=this.getListener(e);if(n){t=t||{},t.type=e,t.target=t.target||this;for(var i=-1;++i<n.length;)n[i](t)}return this},e.prototype.getListener=function(e){var t=this._eventMap?this._eventMap[e]:null;return t||null},e.prototype.destroy=function(){if(this._eventMap){for(var e in this._eventMap)this.removeAllListener(e);this._eventMap=null}return this._destroyed=!0,this},e}();n["default"]=s,t.exports=n["default"]},{}]},{},[1])(1)}); |
@@ -1,3 +0,4 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:true});function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function')}}function isEmpty(obj){for(var prop in obj){if(obj.hasOwnProperty(prop)){return false}}return true}var _instanceMap={};var EventDispatcher=function(){function EventDispatcher(){_classCallCheck(this,EventDispatcher);this._eventMap={};this._destroyed=false;//Method Map | ||
this.on=this.bind=this.addEventListener=this.addListener;this.off=this.unbind=this.removeEventListener=this.removeListener;this.once=this.one=this.addListenerOnce;this.emmit=this.trigger=this.dispatchEvent=this.dispatch}EventDispatcher.getInstance=function getInstance(key){if(!key){throw new Error('key must be')}return _instanceMap[key]||(_instanceMap[key]=new EventDispatcher)};EventDispatcher.prototype.addListener=function addListener(event,listener){var listeners=this.getListener(event);if(!listeners){this._eventMap[event]=[listener]}else if(listeners.indexOf(listener)===-1){listeners.push(listener)}return this};EventDispatcher.prototype.addListenerOnce=function addListenerOnce(event,listener){var _this=this,_arguments=arguments;var s=this;var f2=function f2(){s.removeListener(event,f2);return listener.apply(_this,_arguments)};return this.addListener(event,f2)};EventDispatcher.prototype.removeListener=function removeListener(event,listener){if(typeof listener==='undefined'){return this.removeAllListener(event)}var listeners=this.getListener(event);if(listeners){var i=listeners.indexOf(listener);if(i>-1){listeners=listeners.splice(i,1);if(!listeners.length){delete this._eventMap[event]}}}return this};EventDispatcher.prototype.removeAllListener=function removeAllListener(event){var listeners=this.getListener(event);if(listeners){this._eventMap[event].length=0;delete this._eventMap[event]}return this};EventDispatcher.prototype.hasListener=function hasListener(event){return this.getListener(event)!==null};EventDispatcher.prototype.hasListeners=function hasListeners(){return this._eventMap!==null&&this._eventMap!==undefined&&!isEmpty(this._eventMap)};EventDispatcher.prototype.dispatch=function dispatch(eventType,eventObject){var listeners=this.getListener(eventType);if(listeners){eventObject=eventObject||{};eventObject.type=eventType;eventObject.target=eventObject.target||this;var i=-1;while(++i<listeners.length){listeners[i](eventObject)}// return true; | ||
}return this};EventDispatcher.prototype.getListener=function getListener(event){var result=this._eventMap?this._eventMap[event]:null;return result||null};EventDispatcher.prototype.destroy=function destroy(){if(this._eventMap){for(var i in this._eventMap){this.removeAllListener(i)}this._eventMap=null}this._destroyed=true;return this};return EventDispatcher}();exports.default=EventDispatcher;module.exports=exports['default']; | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:true});function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function')}}function isEmpty(obj){for(var prop in obj){if(obj.hasOwnProperty(prop)){return false}}return true}var _instanceMap={};var EventDispatcher=function(){function EventDispatcher(){_classCallCheck(this,EventDispatcher);this._eventMap={};this._destroyed=false;this.on=this.bind=this.addEventListener=this.addListener;this.off=this.unbind=this.removeEventListener=this.removeListener;this.once=this.one=this.addListenerOnce;this.emit=this.trigger=this.dispatchEvent=this.dispatch}EventDispatcher.getInstance=function getInstance(key){if(!key){throw new Error('key must be')}return _instanceMap[key]||(_instanceMap[key]=new EventDispatcher)};EventDispatcher.prototype.addListener=function addListener(event,listener){var listeners=this.getListener(event);if(!listeners){this._eventMap[event]=[listener]}else if(listeners.indexOf(listener)===-1){listeners.push(listener)}return this};EventDispatcher.prototype.addListenerOnce=function addListenerOnce(event,listener){var _this=this;var _f=function f2(e){listener(e);_this.off(event,_f);listener=null;_f=null};return this.on(event,_f)};EventDispatcher.prototype.removeListener=function removeListener(event,listener){if(!listener){return this.removeAllListener(event)}var listeners=this.getListener(event);if(listeners){var i=listeners.indexOf(listener);if(i>-1){listeners=listeners.splice(i,1);if(!listeners.length){delete this._eventMap[event]}}}return this};EventDispatcher.prototype.removeAllListener=function removeAllListener(event){var listeners=this.getListener(event);if(listeners){this._eventMap[event].length=0;delete this._eventMap[event]}return this};EventDispatcher.prototype.hasListener=function hasListener(event){return this.getListener(event)!==null};EventDispatcher.prototype.hasListeners=function hasListeners(){return this._eventMap!==null&&this._eventMap!==undefined&&!isEmpty(this._eventMap)};EventDispatcher.prototype.dispatch=function dispatch(eventType,eventObject){var listeners=this.getListener(eventType);if(listeners){eventObject=eventObject||{};eventObject.type=eventType;// eventObject.stopPropagation = ()=> { | ||
// eventObject._stopPropagation = true; | ||
// }; | ||
eventObject.target=eventObject.target||this;var i=-1;while(++i<listeners.length){listeners[i](eventObject)}}return this};EventDispatcher.prototype.getListener=function getListener(event){var result=this._eventMap?this._eventMap[event]:null;return result||null};EventDispatcher.prototype.destroy=function destroy(){if(this._eventMap){for(var i in this._eventMap){this.removeAllListener(i)}this._eventMap=null}this._destroyed=true;return this};return EventDispatcher}();exports.default=EventDispatcher;module.exports=exports['default']; |
{ | ||
"name": "eventdispatcher", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "EventDispatcher like nodes EventEmitter", | ||
@@ -8,12 +8,12 @@ "main": "dist/eventdispatcher.js", | ||
"scripts": { | ||
"test": "node test", | ||
"build-js": "browserify --fast -e src/eventdispatcher.js -d --standalone EventDispatcher -t babelify | derequire | exorcist dist/eventdispatcher.browser.js.map > dist/eventdispatcher.browser.js", | ||
"dist-js": "BABEL_ENV=production NODE_ENV=production browserify -e src/eventdispatcher.js --standalone EventDispatcher -t babelify | derequire > dist/eventdispatcher.browser.js", | ||
"dist-js-min": "uglifyjs -cmv dist/eventdispatcher.browser.js > dist/eventdispatcher.browser.min.js", | ||
"dist": "npm run dist-js && npm run dist-js-min && npm run build-lib", | ||
"start": "run-p watch-js server", | ||
"build-lib": "BABEL_ENV=production babel src -d dist", | ||
"watch-js": "watchify -d --poll=100 --fast --standalone EventDispatcher -e src/eventdispatcher.js -t babelify -o 'exorcist dist/eventdispatcher.browser.js.map > dist/eventdispatcher.browser.js' -v", | ||
"server": "browser-sync start --no-ghost-mode --server --directory --files 'examples/**/**, dist/*.js' --startPath examples/index.html" | ||
}, | ||
"test": "node test", | ||
"build-js": "browserify --fast -e src/eventdispatcher.js -d --standalone EventDispatcher -t babelify | derequire | exorcist dist/eventdispatcher.browser.js.map > dist/eventdispatcher.browser.js", | ||
"dist-js": "BABEL_ENV=production NODE_ENV=production browserify -e src/eventdispatcher.js --standalone EventDispatcher -t babelify | derequire > dist/eventdispatcher.browser.js", | ||
"dist-js-min": "uglifyjs -cmv dist/eventdispatcher.browser.js > dist/eventdispatcher.browser.min.js", | ||
"dist": "npm run dist-js && npm run dist-js-min && npm run build-lib", | ||
"start": "run-p watch-js server", | ||
"build-lib": "BABEL_ENV=production babel src -d dist", | ||
"watch-js": "watchify -d --poll=100 --fast --standalone EventDispatcher -e src/eventdispatcher.js -t babelify -o 'exorcist dist/eventdispatcher.browser.js.map > dist/eventdispatcher.browser.js' -v", | ||
"server": "browser-sync start --no-ghost-mode --server --directory --files 'examples/**/**, dist/*.js' --startPath examples/index.html" | ||
}, | ||
"repository": { | ||
@@ -24,5 +24,8 @@ "type": "git", | ||
"keywords": [ | ||
"trigger", | ||
"dispatch", | ||
"event", | ||
"dispatcher", | ||
"emit", | ||
"emitter", | ||
"observer" | ||
@@ -38,21 +41,21 @@ ], | ||
"babel-cli": "6.14.0", | ||
"babel-core": "6.14.0", | ||
"babel-plugin-add-module-exports": "0.2.1", | ||
"babel-plugin-transform-class-constructor-call": "6.8.0", | ||
"babel-plugin-transform-class-properties": "6.11.5", | ||
"babel-plugin-transform-decorators-legacy": "1.3.4", | ||
"babel-plugin-transform-es2015-classes": "6.14.0", | ||
"babel-plugin-transform-proto-to-assign": "6.9.0", | ||
"babel-plugin-transform-remove-console": "6.8.0", | ||
"babel-preset-es2015": "6.14.0", | ||
"babel-preset-stage-0": "6.5.0", | ||
"babelify": "7.3.0", | ||
"browser-sync": "2.14.3", | ||
"browserify": "13.1.0", | ||
"derequire": "2.0.3", | ||
"exorcist": "0.4.0", | ||
"npm-run-all": "3.0.0", | ||
"uglifyjs": "2.4.10", | ||
"watchify": "3.7.0" | ||
"babel-core": "6.14.0", | ||
"babel-plugin-add-module-exports": "0.2.1", | ||
"babel-plugin-transform-class-constructor-call": "6.8.0", | ||
"babel-plugin-transform-class-properties": "6.11.5", | ||
"babel-plugin-transform-decorators-legacy": "1.3.4", | ||
"babel-plugin-transform-es2015-classes": "6.14.0", | ||
"babel-plugin-transform-proto-to-assign": "6.9.0", | ||
"babel-plugin-transform-remove-console": "6.8.0", | ||
"babel-preset-es2015": "6.14.0", | ||
"babel-preset-stage-0": "6.5.0", | ||
"babelify": "7.3.0", | ||
"browser-sync": "2.15.0", | ||
"browserify": "13.1.0", | ||
"derequire": "2.0.3", | ||
"exorcist": "0.4.0", | ||
"npm-run-all": "3.1.0", | ||
"uglifyjs": "2.4.10", | ||
"watchify": "3.7.0" | ||
} | ||
} |
@@ -16,3 +16,2 @@ 'use strict'; | ||
constructor() { | ||
@@ -22,8 +21,6 @@ this._eventMap = {}; | ||
//Method Map | ||
this.on = this.bind = this.addEventListener = this.addListener; | ||
this.off = this.unbind = this.removeEventListener = this.removeListener; | ||
this.once = this.one = this.addListenerOnce; | ||
this.emmit = this.trigger = this.dispatchEvent = this.dispatch; | ||
this.emit = this.trigger = this.dispatchEvent = this.dispatch; | ||
} | ||
@@ -36,3 +33,3 @@ | ||
return _instanceMap[key] || (_instanceMap[key] = new EventDispatcher()); | ||
} | ||
}; | ||
@@ -51,8 +48,9 @@ | ||
addListenerOnce(event, listener) { | ||
var s = this; | ||
var f2 = () => { | ||
s.removeListener(event, f2); | ||
return listener.apply(this, arguments); | ||
var f2 = (e) => { | ||
listener(e); | ||
this.off(event, f2); | ||
listener = null; | ||
f2 = null; | ||
}; | ||
return this.addListener(event, f2); | ||
return this.on(event, f2); | ||
} | ||
@@ -62,3 +60,3 @@ | ||
if (typeof listener === 'undefined') { | ||
if (!listener) { | ||
return this.removeAllListener(event); | ||
@@ -103,2 +101,5 @@ } | ||
eventObject.type = eventType; | ||
// eventObject.stopPropagation = ()=> { | ||
// eventObject._stopPropagation = true; | ||
// }; | ||
eventObject.target = eventObject.target || this; | ||
@@ -110,3 +111,2 @@ | ||
} | ||
// return true; | ||
} | ||
@@ -113,0 +113,0 @@ return this; |
@@ -7,3 +7,3 @@ //TODO implement real test. | ||
var handler = function(event) { | ||
console.log(event.type + ' was triggered'); | ||
console.log('>> '+event.type + ' was triggered'); | ||
}; | ||
@@ -14,30 +14,62 @@ | ||
console.log('dispatcher.on(evt1).....', dispatcher.on('evt1', handler)); | ||
console.log('dispatcher.on(evt1).....'); | ||
dispatcher.on('evt1', handler) | ||
console.log('dispatcher.hasListeners', dispatcher.hasListeners()); | ||
console.log('dispatcher.hasListener(evt1)', dispatcher.hasListener('evt1')); | ||
console.log('dispatcher.hasListener(evt2)', dispatcher.hasListener('evt2')); | ||
console.log('dispatcher.on(evt2).....', dispatcher.on('evt2', handler)); | ||
console.log('dispatcher.on(evt2).....', dispatcher.on('evt2', handler)); | ||
console.log('dispatcher.on(evt2).....', dispatcher.on('evt2', handler)); | ||
console.log('dispatcher.on(evt2).....', dispatcher.on('evt2', handler)); | ||
console.log('dispatcher.on(evt2).....'); | ||
dispatcher.on('evt2', handler); | ||
console.log('dispatcher.on(evt2).....'); | ||
dispatcher.on('evt2', handler); | ||
console.log('dispatcher.on(evt2).....'); | ||
dispatcher.on('evt2', handler); | ||
console.log('dispatcher.once(test).....'); | ||
dispatcher.once('test', handler); | ||
console.log('trigger(test)'); | ||
console.log('trigger(test)'); | ||
console.log('trigger(test)'); | ||
console.log('trigger(test)'); | ||
console.log('trigger(test)'); | ||
dispatcher.dispatch('test'); | ||
dispatcher.dispatch('test'); | ||
dispatcher.dispatch('test'); | ||
dispatcher.dispatch('test'); | ||
dispatcher.dispatch('test'); | ||
console.log('dispatcher.once(evt2).....'); | ||
dispatcher.once('evt2', handler); | ||
console.log('dispatcher.hasListener(evt2)', dispatcher.hasListener('evt2')); | ||
console.log('trigger(evt1)', dispatcher.trigger('evt1')); | ||
console.log('trigger(evt2)', dispatcher.trigger('evt2')); | ||
console.log('trigger(evt1)'); | ||
dispatcher.trigger('evt1') | ||
console.log('trigger(evt2)'); | ||
dispatcher.trigger('evt2'); | ||
console.log('dispatcher.off(evt2)', dispatcher.off('evt2')); | ||
console.log('dispatcher.off(evt2)', dispatcher.off('evt2')); | ||
console.log('dispatcher.off(evt2)', dispatcher.off('evt2')); | ||
console.log('trigger(evt2)'); | ||
dispatcher.trigger('evt2'); | ||
console.log('trigger(evt1)', dispatcher.trigger('evt1')); | ||
console.log('trigger(evt2)', dispatcher.trigger('evt2')); | ||
console.log('dispatcher.off(evt2)'); | ||
dispatcher.off('evt2') | ||
console.log('dispatcher.off(evt2)'); | ||
dispatcher.off('evt2') | ||
console.log('dispatcher.off(evt2)'); | ||
dispatcher.off('evt2') | ||
console.log('tdestroy', dispatcher.destroy()); | ||
console.log('trigger(evt1)'); | ||
dispatcher.trigger('evt1') | ||
console.log('trigger(evt2)'); | ||
dispatcher.trigger('evt2'); | ||
console.log('trigger(evt1)', dispatcher.trigger('evt1')); | ||
console.log('trigger(evt2)', dispatcher.trigger('evt2')); | ||
console.log('destroy'); dispatcher.destroy() | ||
console.log('trigger(evt1)'); | ||
dispatcher.trigger('evt1') | ||
console.log('trigger(evt2)'); | ||
dispatcher.trigger('evt2'); | ||
dispatcher.trigger('evt1'); | ||
@@ -44,0 +76,0 @@ dispatcher.trigger('evt2'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22440
214
0