diff --git a/dist/event-dispatcher.direct.js b/dist/event-dispatcher.direct.js index ba3d424..b36a2d3 100644 --- a/dist/event-dispatcher.direct.js +++ b/dist/event-dispatcher.direct.js @@ -1,2 +1,2 @@ -var EventDispatcher=function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="http://localhost:8081/dist/",t(t.s=0)}([function(e,t,n){"use strict";var i=n(1),r=function(e){return e&&e.__esModule?e:{default:e}}(i);e.exports=r.default},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n=0&&(s.splice(u,1),s.length||delete i[o],n._runners.forEach(function(e){e.listenerRemoved(s,u)}))}(s)}},{key:"removeAll",value:function(e){delete this._listeners[e]}},{key:"createRunner",value:function(e,t){var n=new a(e,t,this.removeRunner);return this._runners.push(n),n}},{key:"call",value:function(e,t){var n=this.getPrioritiesByKey(e.type),i=!1,r=function(){i=!0};if(n)for(var o=Object.getOwnPropertyNames(n).sort(function(e,t){return e-t}),s=o.length,u=0;u1&&void 0!==arguments[1]&&arguments[1];i(this,e),n||this.initialize(t)}return o(e,[{key:"initialize",value:function(e){this._eventPreprocessor=e,this._listeners=new l}},{key:"addEventListener",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this._listeners.add(e,t,-n||0)}},{key:"hasEventListener",value:function(e){return this._listeners.has(e)}},{key:"removeEventListener",value:function(e,t){this._listeners.remove(e,t)}},{key:"removeAllEventListeners",value:function(e){this._listeners.removeAll(e)}},{key:"dispatchEvent",value:function(t,n){var i=e.getEvent(t,n);this._eventPreprocessor&&(i=this._eventPreprocessor.call(this,i)),this._listeners.call(i)}}],[{key:"isObject",value:function(e){return"object"===(void 0===e?"undefined":r(e))&&null!==e}},{key:"getEvent",value:function(t,n){var i=t;return e.isObject(t)||(i=new e.Event(String(t),n)),i}},{key:"create",value:function(t){return new e(t)}}]),e}();c.Event=u,t.default=c}]); +var EventDispatcher=function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="http://localhost:8081/dist/",t(t.s=0)}([function(e,t,n){"use strict";var i=n(1),r=function(e){return e&&e.__esModule?e:{default:e}}(i);e.exports=r.default},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:null;i(this,e),this.type=t,this.data=n,this.defaultPrevented=!1}return o(e,[{key:"toJSON",value:function(){return{type:this.type,data:this.data}}},{key:"isDefaultPrevented",value:function(){return this.defaultPrevented}},{key:"preventDefault",value:function(){this.defaultPrevented=!0}}]),e}(),a=function(){function e(t,n,r){var o=this;i(this,e),this.index=-1,this.immediatelyStopped=!1,this.stopImmediatePropagation=function(){o.immediatelyStopped=!0},this.listeners=t,this.onStopped=n,this.onComplete=r}return o(e,[{key:"run",value:function(e,t){var n=void 0,i=this.listeners;for(this.augmentEvent(e),this.index=0;this.index=0&&(s.splice(u,1),s.length||delete i[o],n._runners.forEach(function(e){e.listenerRemoved(s,u)}))}(s)}},{key:"removeAll",value:function(e){delete this._listeners[e]}},{key:"createRunner",value:function(e,t){var n=new a(e,t,this.removeRunner);return this._runners.push(n),n}},{key:"call",value:function(e,t){var n=this.getPrioritiesByKey(e.type),i=!1,r=function(){i=!0};if(n)for(var o=Object.getOwnPropertyNames(n).sort(function(e,t){return e-t}),s=o.length,u=0;u0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i(this,e),n||this.initialize(t)}return o(e,[{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._eventPreprocessor=e,this._listeners=new l}},{key:"addEventListener",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this._listeners.add(e,t,-n||0)}},{key:"hasEventListener",value:function(e){return this._listeners.has(e)}},{key:"removeEventListener",value:function(e,t){this._listeners.remove(e,t)}},{key:"removeAllEventListeners",value:function(e){this._listeners.removeAll(e)}},{key:"dispatchEvent",value:function(t,n){var i=e.getEvent(t,n);this._eventPreprocessor&&(i=this._eventPreprocessor.call(this,i)),this._listeners.call(i)}}],[{key:"isObject",value:function(e){return"object"===(void 0===e?"undefined":r(e))&&null!==e}},{key:"getEvent",value:function(t,n){var i=t;return e.isObject(t)||(i=new e.Event(String(t),n)),i}},{key:"create",value:function(t){return new e(t)}}]),e}();c.Event=u,t.default=c}]); //# sourceMappingURL=event-dispatcher.direct.js.map \ No newline at end of file diff --git a/dist/event-dispatcher.direct.js.map b/dist/event-dispatcher.direct.js.map index 5ca32f1..0d50f88 100644 --- a/dist/event-dispatcher.direct.js.map +++ b/dist/event-dispatcher.direct.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///event-dispatcher.direct.js","webpack:///webpack/bootstrap 951e20216918c0216c79","webpack:///./source/direct.js","webpack:///./source/EventDispatcher.js"],"names":["EventDispatcher","modules","__webpack_require__","moduleId","installedModules","exports","module","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_EventDispatcher","_EventDispatcher2","obj","default","_classCallCheck","instance","Constructor","TypeError","value","_typeof","Symbol","iterator","constructor","_createClass","defineProperties","target","props","length","descriptor","writable","key","protoProps","staticProps","hasOwnProp","Event","type","data","this","defaultPrevented","ListenersRunner","listeners","onStopped","onComplete","_this","index","immediatelyStopped","stopImmediatePropagation","event","listener","augmentEvent","clearEvent","eventObject","stopPropagation","EventListeners","_this2","_listeners","_runners","removeRunner","runner","splice","indexOf","eventType","priorityOpt","priority","parseInt","getPrioritiesByKey","String","handler","handlers","createList","push","result","priorities","_this3","list","getOwnPropertyNames","handlerIndex","forEach","listenerRemoved","stopped","sort","a","b","createRunner","run","eventPreprocessor","noInit","arguments","undefined","initialize","_eventPreprocessor","add","has","remove","removeAll","getEvent","eventOrType","optionalData","isObject"],"mappings":"AAAA,GAAIA,iBACK,SAAUC,GCGnB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAI,EAAAJ,EACAK,GAAA,EACAH,WAUA,OANAJ,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,GAAA,EAGAF,EAAAD,QAvBA,GAAAD,KA4DA,OAhCAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAU,EAAA,SAAAP,EAAAQ,EAAAC,GACAZ,EAAAa,EAAAV,EAAAQ,IACAG,OAAAC,eAAAZ,EAAAQ,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAZ,EAAAmB,EAAA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MA7DA9D,GAAa1C,IACXiD,IAAK,aACLZ,MAAO,SGxHEmE,GACThD,KAAKqD,mBAAqBL,EAC1BhD,KAAKkB,WAAa,GAAIF,MH2HtBvB,IAAK,mBACLZ,MAAO,SGzHQ2C,EAAmBb,GAA+C,GAAtBe,GAAsBwB,UAAA5D,OAAA,OAAA6D,KAAAD,UAAA,GAAAA,UAAA,GAAH,CAC9ElD,MAAKkB,WAAWoC,IAAI9B,EAAWb,GAAWe,GAAY,MH8HtDjC,IAAK,mBACLZ,MAAO,SG5HQ2C,GACf,MAAOxB,MAAKkB,WAAWqC,IAAI/B,MH+H3B/B,IAAK,sBACLZ,MAAO,SG7HW2C,EAAmBb,GACrCX,KAAKkB,WAAWsC,OAAOhC,EAAWb,MHgIlClB,IAAK,0BACLZ,MAAO,SG9He2C,GACtBxB,KAAKkB,WAAWuC,UAAUjC,MHiI1B/B,IAAK,gBACLZ,MAAO,SG/HK6B,EAAkBX,GAC9B,GAAIe,GAActE,EAAgBkH,SAAShD,EAAOX,EAC9CC,MAAKqD,qBACPvC,EAAcd,KAAKqD,mBAAmBpG,KAAK+C,KAAMc,IAEnDd,KAAKkB,WAAWjE,KAAK6D,QHkIrBrB,IAAK,WACLZ,MAAO,SGhIOA,GACd,MAAyB,gBAAjB,KAAOA,EAAP,YAAAC,EAAOD,KAAkC,OAAVA,KHmIvCY,IAAK,WACLZ,MAAO,SGjIO8E,EAAwBC,GACtC,GAAIlD,GAAQiD,CAIZ,OAHKnH,GAAgBqH,SAASF,KAC5BjD,EAAQ,GAAIlE,GAAgBqD,MAAMgC,OAAO8B,GAAcC,IAEjDlD,KHoIRjB,IAAK,SACLZ,MAAO,SGlIKmE,GACZ,MAAO,IAAIxG,GAAgBwG,OHyItBxG,IGlITA,GAAgBqD,MAAQA,EHuIxBhD,EAAQ2B,QGrIOhC","file":"event-dispatcher.direct.js","sourcesContent":["var EventDispatcher =\n/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"http://localhost:8081/dist/\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _EventDispatcher = __webpack_require__(1);\n\nvar _EventDispatcher2 = _interopRequireDefault(_EventDispatcher);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nmodule.exports = _EventDispatcher2.default;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar hasOwnProp = function hasOwnProp(target, name) {\n return Object.prototype.hasOwnProperty.call(target, name);\n}; /**\n * Created by Oleg Galaburda on 09.02.16.\n * \n */\n\nvar Event = exports.Event = function () {\n function Event(type, data) {\n _classCallCheck(this, Event);\n\n this.type = type;\n this.data = data || null;\n this.defaultPrevented = false;\n }\n\n _createClass(Event, [{\n key: 'toJSON',\n value: function toJSON() {\n return { type: this.type, data: this.data };\n }\n }, {\n key: 'isDefaultPrevented',\n value: function isDefaultPrevented() {\n return this.defaultPrevented;\n }\n }, {\n key: 'preventDefault',\n value: function preventDefault() {\n this.defaultPrevented = true;\n }\n }]);\n\n return Event;\n}();\n\nvar ListenersRunner = function () {\n function ListenersRunner(listeners, onStopped, onComplete) {\n var _this = this;\n\n _classCallCheck(this, ListenersRunner);\n\n this.index = -1;\n this.immediatelyStopped = false;\n\n this.stopImmediatePropagation = function () {\n _this.immediatelyStopped = true;\n };\n\n this.listeners = listeners;\n this.onStopped = onStopped;\n this.onComplete = onComplete;\n }\n\n _createClass(ListenersRunner, [{\n key: 'run',\n value: function run(event, target) {\n var listener = void 0;\n var listeners = this.listeners;\n\n this.augmentEvent(event);\n // TODO this has to be handled in separate object ListenersRunner that should be\n // created for each call() call and asked for index validation on each listener remove.\n for (this.index = 0; this.index < listeners.length; this.index++) {\n if (this.immediatelyStopped) break;\n listener = listeners[this.index];\n listener.call(target, event);\n }\n this.clearEvent(event);\n this.onComplete(this);\n }\n }, {\n key: 'augmentEvent',\n value: function augmentEvent(eventObject) {\n var event = eventObject;\n event.stopPropagation = this.onStopped;\n event.stopImmediatePropagation = this.stopImmediatePropagation;\n }\n\n /* eslint class-methods-use-this: \"off\" */\n\n }, {\n key: 'clearEvent',\n value: function clearEvent(eventObject) {\n var event = eventObject;\n delete event.stopPropagation;\n delete event.stopImmediatePropagation;\n }\n }, {\n key: 'listenerRemoved',\n value: function listenerRemoved(listeners, index) {\n if (listeners === this.listeners && index <= this.index) {\n this.index--;\n }\n }\n }]);\n\n return ListenersRunner;\n}();\n\nvar EventListeners = function () {\n function EventListeners() {\n var _this2 = this;\n\n _classCallCheck(this, EventListeners);\n\n this._listeners = {};\n this._runners = [];\n\n this.removeRunner = function (runner) {\n _this2._runners.splice(_this2._runners.indexOf(runner), 1);\n };\n }\n /**\n * key - event Type\n * value - hash of priorities\n * key - priority\n * value - list of handlers\n * @type {Object>>}\n * @private\n */\n\n\n _createClass(EventListeners, [{\n key: 'createList',\n value: function createList(eventType, priorityOpt) {\n var priority = parseInt(priorityOpt, 10);\n var target = this.getPrioritiesByKey(eventType);\n var key = String(priority);\n var value = void 0;\n if (hasOwnProp(target, key)) {\n value = target[key];\n } else {\n value = [];\n target[key] = value;\n }\n return value;\n }\n }, {\n key: 'getPrioritiesByKey',\n value: function getPrioritiesByKey(key) {\n var value = void 0;\n if (hasOwnProp(this._listeners, key)) {\n value = this._listeners[key];\n } else {\n value = {};\n this._listeners[key] = value;\n }\n return value;\n }\n }, {\n key: 'add',\n value: function add(eventType, handler, priority) {\n var handlers = this.createList(eventType, priority);\n if (handlers.indexOf(handler) < 0) {\n handlers.push(handler);\n }\n }\n }, {\n key: 'has',\n value: function has(eventType) {\n var priority = void 0;\n var result = false;\n var priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n for (priority in priorities) {\n if (hasOwnProp(priorities, priority)) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n }, {\n key: 'remove',\n value: function remove(eventType, handler) {\n var _this3 = this;\n\n var priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n var list = Object.getOwnPropertyNames(priorities);\n var length = list.length;\n\n var _loop = function _loop(index) {\n var priority = list[index];\n var handlers = priorities[priority];\n var handlerIndex = handlers.indexOf(handler);\n if (handlerIndex >= 0) {\n handlers.splice(handlerIndex, 1);\n if (!handlers.length) {\n delete priorities[priority];\n }\n _this3._runners.forEach(function (runner) {\n runner.listenerRemoved(handlers, handlerIndex);\n });\n }\n };\n\n for (var index = 0; index < length; index++) {\n _loop(index);\n }\n }\n }\n }, {\n key: 'removeAll',\n value: function removeAll(eventType) {\n delete this._listeners[eventType];\n }\n }, {\n key: 'createRunner',\n value: function createRunner(handlers, onStopped) {\n var runner = new ListenersRunner(handlers, onStopped, this.removeRunner);\n this._runners.push(runner);\n return runner;\n }\n }, {\n key: 'call',\n value: function call(event, target) {\n var priorities = this.getPrioritiesByKey(event.type);\n var stopped = false;\n var stopPropagation = function stopPropagation() {\n stopped = true;\n };\n if (priorities) {\n // getOwnPropertyNames() or keys()?\n var list = Object.getOwnPropertyNames(priorities).sort(function (a, b) {\n return a - b;\n });\n var length = list.length;\n\n for (var index = 0; index < length; index++) {\n if (stopped) break;\n var _handlers = priorities[list[index]];\n // in case if all handlers of priority were removed while event\n // was dispatched and handlers become undefined.\n if (_handlers) {\n var _runner = this.createRunner(_handlers, stopPropagation);\n _runner.run(event, target);\n if (_runner.immediatelyStopped) break;\n }\n }\n }\n }\n }]);\n\n return EventListeners;\n}();\n\nvar EventDispatcher = function () {\n function EventDispatcher(eventPreprocessor) {\n var noInit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\n _classCallCheck(this, EventDispatcher);\n\n if (!noInit) {\n this.initialize(eventPreprocessor);\n }\n }\n\n /**\n * @private\n */\n\n\n _createClass(EventDispatcher, [{\n key: 'initialize',\n value: function initialize(eventPreprocessor) {\n this._eventPreprocessor = eventPreprocessor;\n this._listeners = new EventListeners();\n }\n }, {\n key: 'addEventListener',\n value: function addEventListener(eventType, listener) {\n var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n\n this._listeners.add(eventType, listener, -priority || 0);\n }\n }, {\n key: 'hasEventListener',\n value: function hasEventListener(eventType) {\n return this._listeners.has(eventType);\n }\n }, {\n key: 'removeEventListener',\n value: function removeEventListener(eventType, listener) {\n this._listeners.remove(eventType, listener);\n }\n }, {\n key: 'removeAllEventListeners',\n value: function removeAllEventListeners(eventType) {\n this._listeners.removeAll(eventType);\n }\n }, {\n key: 'dispatchEvent',\n value: function dispatchEvent(event, data) {\n var eventObject = EventDispatcher.getEvent(event, data);\n if (this._eventPreprocessor) {\n eventObject = this._eventPreprocessor.call(this, eventObject);\n }\n this._listeners.call(eventObject);\n }\n }], [{\n key: 'isObject',\n value: function isObject(value) {\n return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;\n }\n }, {\n key: 'getEvent',\n value: function getEvent(eventOrType, optionalData) {\n var event = eventOrType;\n if (!EventDispatcher.isObject(eventOrType)) {\n event = new EventDispatcher.Event(String(eventOrType), optionalData);\n }\n return event;\n }\n }, {\n key: 'create',\n value: function create(eventPreprocessor) {\n return new EventDispatcher(eventPreprocessor);\n }\n\n /* eslint no-undef: \"off\" */\n\n }]);\n\n return EventDispatcher;\n}();\n\nEventDispatcher.Event = Event;\n\nexports.default = EventDispatcher;\n\n/***/ })\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// event-dispatcher.direct.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"http://localhost:8081/dist/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 951e20216918c0216c79","import EventDispatcher from './EventDispatcher';\n\nmodule.exports = EventDispatcher;\n\n\n\n// WEBPACK FOOTER //\n// ./source/direct.js","/**\n * Created by Oleg Galaburda on 09.02.16.\n * @flow\n */\n\nimport type {\n EventObject,\n EventType,\n EventListener,\n EventProcessor,\n IEvent,\n IEventDispatcher,\n} from './TypeDefinition';\n\nconst hasOwnProp = (target: any, name: string): boolean => (\n Object.prototype.hasOwnProperty.call(target, name)\n);\n\nexport class Event implements IEvent {\n\n type: string;\n data: mixed;\n defaultPrevented: boolean;\n stopPropagation: ?() => void;\n stopImmediatePropagation: ?() => void;\n\n constructor(type: string, data: mixed) {\n this.type = type;\n this.data = data || null;\n this.defaultPrevented = false;\n }\n\n toJSON(): EventObject {\n return { type: this.type, data: this.data };\n }\n\n isDefaultPrevented(): boolean {\n return this.defaultPrevented;\n }\n\n preventDefault() {\n this.defaultPrevented = true;\n }\n}\n\ntype EventPrioritiesCollection = {\n [priority: string]: Array;\n}\n\ntype EventTypesCollection = {\n [eventType: string]: EventPrioritiesCollection;\n}\n\nclass ListenersRunner {\n index: number = -1;\n immediatelyStopped: boolean = false;\n listeners: EventListener[];\n onStopped: (runner: ListenersRunner) => void;\n onComplete: (runner: ListenersRunner) => void;\n\n constructor(\n listeners: EventListener[],\n onStopped: (runner: ListenersRunner) => void,\n onComplete: (runner: ListenersRunner) => void,\n ) {\n this.listeners = listeners;\n this.onStopped = onStopped;\n this.onComplete = onComplete;\n }\n\n stopImmediatePropagation = () => {\n this.immediatelyStopped = true;\n };\n\n run(event: EventObject, target: any) {\n let listener: EventListener;\n const { listeners } = this;\n this.augmentEvent(event);\n // TODO this has to be handled in separate object ListenersRunner that should be\n // created for each call() call and asked for index validation on each listener remove.\n for (this.index = 0; this.index < listeners.length; this.index++) {\n if (this.immediatelyStopped) break;\n listener = listeners[this.index];\n listener.call(target, event);\n }\n this.clearEvent(event);\n this.onComplete(this);\n }\n\n augmentEvent(eventObject: EventObject) {\n const event: EventObject = eventObject;\n event.stopPropagation = this.onStopped;\n event.stopImmediatePropagation = this.stopImmediatePropagation;\n }\n\n /* eslint class-methods-use-this: \"off\" */\n clearEvent(eventObject: EventObject) {\n const event: EventObject = eventObject;\n delete event.stopPropagation;\n delete event.stopImmediatePropagation;\n }\n\n listenerRemoved(listeners: EventListener[], index: number) {\n if (listeners === this.listeners && index <= this.index) {\n this.index--;\n }\n }\n}\n\nclass EventListeners {\n /**\n * key - event Type\n * value - hash of priorities\n * key - priority\n * value - list of handlers\n * @type {Object>>}\n * @private\n */\n _listeners: EventTypesCollection = {};\n _runners: ListenersRunner[] = [];\n\n createList(eventType: string, priorityOpt?: mixed): Array {\n const priority: number = parseInt(priorityOpt, 10);\n const target: EventPrioritiesCollection = this.getPrioritiesByKey(eventType);\n const key: string = String(priority);\n let value: Array;\n if (hasOwnProp(target, key)) {\n value = target[key];\n } else {\n value = [];\n target[key] = value;\n }\n return value;\n }\n\n getPrioritiesByKey(key: string): EventPrioritiesCollection {\n let value: EventPrioritiesCollection;\n if (hasOwnProp(this._listeners, key)) {\n value = this._listeners[key];\n } else {\n value = {};\n this._listeners[key] = value;\n }\n return value;\n }\n\n add(eventType: string, handler: EventListener, priority: number) {\n const handlers = this.createList(eventType, priority);\n if (handlers.indexOf(handler) < 0) {\n handlers.push(handler);\n }\n }\n\n has(eventType: string): boolean {\n let priority: string;\n let result = false;\n const priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n for (priority in priorities) {\n if (hasOwnProp(priorities, priority)) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n remove(eventType: string, handler) {\n const priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n const list = Object.getOwnPropertyNames(priorities);\n const { length } = list;\n for (let index = 0; index < length; index++) {\n const priority = list[index];\n const handlers = priorities[priority];\n const handlerIndex = handlers.indexOf(handler);\n if (handlerIndex >= 0) {\n handlers.splice(handlerIndex, 1);\n if (!handlers.length) {\n delete priorities[priority];\n }\n this._runners.forEach((runner) => {\n runner.listenerRemoved(handlers, handlerIndex);\n });\n }\n }\n }\n }\n\n removeAll(eventType: string) {\n delete this._listeners[eventType];\n }\n\n createRunner(handlers, onStopped) {\n const runner = new ListenersRunner(handlers, onStopped, this.removeRunner);\n this._runners.push(runner);\n return runner;\n }\n\n removeRunner = (runner) => {\n this._runners.splice(this._runners.indexOf(runner), 1);\n };\n\n call(event: EventObject, target: any) {\n const priorities = this.getPrioritiesByKey(event.type);\n let stopped = false;\n const stopPropagation = () => {\n stopped = true;\n };\n if (priorities) {\n // getOwnPropertyNames() or keys()?\n const list: string[] = Object\n .getOwnPropertyNames(priorities)\n .sort((a: any, b: any) => (a - b));\n const { length } = list;\n for (let index = 0; index < length; index++) {\n if (stopped) break;\n const handlers: Array = priorities[list[index]];\n // in case if all handlers of priority were removed while event\n // was dispatched and handlers become undefined.\n if (handlers) {\n const runner = this.createRunner(handlers, stopPropagation);\n runner.run(event, target);\n if (runner.immediatelyStopped) break;\n }\n }\n }\n }\n}\n\nclass EventDispatcher implements IEventDispatcher {\n\n _listeners: EventListeners;\n _eventPreprocessor: EventProcessor;\n\n constructor(eventPreprocessor: EventProcessor, noInit: boolean = false) {\n if (!noInit) {\n this.initialize(eventPreprocessor);\n }\n }\n\n /**\n * @private\n */\n initialize(eventPreprocessor: EventProcessor) {\n this._eventPreprocessor = eventPreprocessor;\n this._listeners = new EventListeners();\n }\n\n addEventListener(eventType: string, listener: EventListener, priority: number = 0) {\n this._listeners.add(eventType, listener, -priority || 0);\n }\n\n hasEventListener(eventType: string) {\n return this._listeners.has(eventType);\n }\n\n removeEventListener(eventType: string, listener: EventListener) {\n this._listeners.remove(eventType, listener);\n }\n\n removeAllEventListeners(eventType: string) {\n this._listeners.removeAll(eventType);\n }\n\n dispatchEvent(event: EventType, data: mixed) {\n let eventObject = EventDispatcher.getEvent(event, data);\n if (this._eventPreprocessor) {\n eventObject = this._eventPreprocessor.call(this, eventObject);\n }\n this._listeners.call(eventObject);\n }\n\n static isObject(value: mixed) {\n return (typeof value === 'object') && (value !== null);\n }\n\n static getEvent(eventOrType: EventType, optionalData: mixed): EventObject {\n let event = eventOrType;\n if (!EventDispatcher.isObject(eventOrType)) {\n event = new EventDispatcher.Event(String(eventOrType), optionalData);\n }\n return (event: any);\n }\n\n static create(eventPreprocessor: EventProcessor) {\n return new EventDispatcher(eventPreprocessor);\n }\n\n /* eslint no-undef: \"off\" */\n static Event: Class;\n}\n\nEventDispatcher.Event = Event;\n\nexport default EventDispatcher;\n\n\n\n// WEBPACK FOOTER //\n// ./source/EventDispatcher.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///event-dispatcher.direct.js","webpack:///webpack/bootstrap 838017a37f7a653c0fde","webpack:///./source/direct.js","webpack:///./source/EventDispatcher.js"],"names":["EventDispatcher","modules","__webpack_require__","moduleId","installedModules","exports","module","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_EventDispatcher","_EventDispatcher2","obj","default","_classCallCheck","instance","Constructor","TypeError","value","_typeof","Symbol","iterator","constructor","_createClass","defineProperties","target","props","length","descriptor","writable","key","protoProps","staticProps","hasOwnProp","Event","type","data","arguments","undefined","this","defaultPrevented","ListenersRunner","listeners","onStopped","onComplete","_this","index","immediatelyStopped","stopImmediatePropagation","event","listener","augmentEvent","clearEvent","eventObject","stopPropagation","EventListeners","_this2","_listeners","_runners","removeRunner","runner","splice","indexOf","eventType","priorityOpt","priority","parseInt","getPrioritiesByKey","String","handler","handlers","createList","push","result","priorities","_this3","list","getOwnPropertyNames","handlerIndex","forEach","listenerRemoved","stopped","sort","a","b","createRunner","run","eventPreprocessor","noInit","initialize","_eventPreprocessor","add","has","remove","removeAll","getEvent","eventOrType","optionalData","isObject"],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IAAK,gBACLZ,MAAO,SGpIK+B,EAAkBb,GAC9B,GAAIiB,GAAcxE,EAAgBkH,SAAS9C,EAAOb,EAC9CG,MAAKmD,qBACPrC,EAAcd,KAAKmD,mBAAmBpG,KAAKiD,KAAMc,IAEnDd,KAAKkB,WAAWnE,KAAK+D,QHuIrBvB,IAAK,WACLZ,MAAO,SGrIOA,GACd,MAAyB,gBAAjB,KAAOA,EAAP,YAAAC,EAAOD,KAAkC,OAAVA,KHwIvCY,IAAK,WACLZ,MAAO,SGtIO8E,EAAwBC,GACtC,GAAIhD,GAAQ+C,CAIZ,OAHKnH,GAAgBqH,SAASF,KAC5B/C,EAAQ,GAAIpE,GAAgBqD,MAAMkC,OAAO4B,GAAcC,IAEjDhD,KHyIRnB,IAAK,SACLZ,MAAO,SGvIKqE,GACZ,MAAO,IAAI1G,GAAgB0G,OH8ItB1G,IGvITA,GAAgBqD,MAAQA,EH4IxBhD,EAAQ2B,QG1IOhC","file":"event-dispatcher.direct.js","sourcesContent":["var EventDispatcher =\n/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"http://localhost:8081/dist/\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _EventDispatcher = __webpack_require__(1);\n\nvar _EventDispatcher2 = _interopRequireDefault(_EventDispatcher);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nmodule.exports = _EventDispatcher2.default;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar hasOwnProp = function hasOwnProp(target, name) {\n return Object.prototype.hasOwnProperty.call(target, name);\n}; /**\r\n * Created by Oleg Galaburda on 09.02.16.\r\n * \r\n */\n\nvar Event = exports.Event = function () {\n function Event(type) {\n var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n\n _classCallCheck(this, Event);\n\n this.type = type;\n this.data = data;\n this.defaultPrevented = false;\n }\n\n _createClass(Event, [{\n key: 'toJSON',\n value: function toJSON() {\n return { type: this.type, data: this.data };\n }\n }, {\n key: 'isDefaultPrevented',\n value: function isDefaultPrevented() {\n return this.defaultPrevented;\n }\n }, {\n key: 'preventDefault',\n value: function preventDefault() {\n this.defaultPrevented = true;\n }\n }]);\n\n return Event;\n}();\n\nvar ListenersRunner = function () {\n function ListenersRunner(listeners, onStopped, onComplete) {\n var _this = this;\n\n _classCallCheck(this, ListenersRunner);\n\n this.index = -1;\n this.immediatelyStopped = false;\n\n this.stopImmediatePropagation = function () {\n _this.immediatelyStopped = true;\n };\n\n this.listeners = listeners;\n this.onStopped = onStopped;\n this.onComplete = onComplete;\n }\n\n _createClass(ListenersRunner, [{\n key: 'run',\n value: function run(event, target) {\n var listener = void 0;\n var listeners = this.listeners;\n\n this.augmentEvent(event);\n // TODO this has to be handled in separate object ListenersRunner that should be\n // created for each call() call and asked for index validation on each listener remove.\n for (this.index = 0; this.index < listeners.length; this.index++) {\n if (this.immediatelyStopped) break;\n listener = listeners[this.index];\n listener.call(target, event);\n }\n this.clearEvent(event);\n this.onComplete(this);\n }\n }, {\n key: 'augmentEvent',\n value: function augmentEvent(eventObject) {\n var event = eventObject;\n event.stopPropagation = this.onStopped;\n event.stopImmediatePropagation = this.stopImmediatePropagation;\n }\n\n /* eslint class-methods-use-this: \"off\" */\n\n }, {\n key: 'clearEvent',\n value: function clearEvent(eventObject) {\n var event = eventObject;\n delete event.stopPropagation;\n delete event.stopImmediatePropagation;\n }\n }, {\n key: 'listenerRemoved',\n value: function listenerRemoved(listeners, index) {\n if (listeners === this.listeners && index <= this.index) {\n this.index--;\n }\n }\n }]);\n\n return ListenersRunner;\n}();\n\nvar EventListeners = function () {\n function EventListeners() {\n var _this2 = this;\n\n _classCallCheck(this, EventListeners);\n\n this._listeners = {};\n this._runners = [];\n\n this.removeRunner = function (runner) {\n _this2._runners.splice(_this2._runners.indexOf(runner), 1);\n };\n }\n /**\r\n * key - event Type\r\n * value - hash of priorities\r\n * key - priority\r\n * value - list of handlers\r\n * @type {Object>>}\r\n * @private\r\n */\n\n\n _createClass(EventListeners, [{\n key: 'createList',\n value: function createList(eventType, priorityOpt) {\n var priority = parseInt(priorityOpt, 10);\n var target = this.getPrioritiesByKey(eventType);\n var key = String(priority);\n var value = void 0;\n if (hasOwnProp(target, key)) {\n value = target[key];\n } else {\n value = [];\n target[key] = value;\n }\n return value;\n }\n }, {\n key: 'getPrioritiesByKey',\n value: function getPrioritiesByKey(key) {\n var value = void 0;\n if (hasOwnProp(this._listeners, key)) {\n value = this._listeners[key];\n } else {\n value = {};\n this._listeners[key] = value;\n }\n return value;\n }\n }, {\n key: 'add',\n value: function add(eventType, handler, priority) {\n var handlers = this.createList(eventType, priority);\n if (handlers.indexOf(handler) < 0) {\n handlers.push(handler);\n }\n }\n }, {\n key: 'has',\n value: function has(eventType) {\n var priority = void 0;\n var result = false;\n var priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n for (priority in priorities) {\n if (hasOwnProp(priorities, priority)) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n }, {\n key: 'remove',\n value: function remove(eventType, handler) {\n var _this3 = this;\n\n var priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n var list = Object.getOwnPropertyNames(priorities);\n var length = list.length;\n\n var _loop = function _loop(index) {\n var priority = list[index];\n var handlers = priorities[priority];\n var handlerIndex = handlers.indexOf(handler);\n if (handlerIndex >= 0) {\n handlers.splice(handlerIndex, 1);\n if (!handlers.length) {\n delete priorities[priority];\n }\n _this3._runners.forEach(function (runner) {\n runner.listenerRemoved(handlers, handlerIndex);\n });\n }\n };\n\n for (var index = 0; index < length; index++) {\n _loop(index);\n }\n }\n }\n }, {\n key: 'removeAll',\n value: function removeAll(eventType) {\n delete this._listeners[eventType];\n }\n }, {\n key: 'createRunner',\n value: function createRunner(handlers, onStopped) {\n var runner = new ListenersRunner(handlers, onStopped, this.removeRunner);\n this._runners.push(runner);\n return runner;\n }\n }, {\n key: 'call',\n value: function call(event, target) {\n var priorities = this.getPrioritiesByKey(event.type);\n var stopped = false;\n var stopPropagation = function stopPropagation() {\n stopped = true;\n };\n if (priorities) {\n // getOwnPropertyNames() or keys()?\n var list = Object.getOwnPropertyNames(priorities).sort(function (a, b) {\n return a - b;\n });\n var length = list.length;\n\n for (var index = 0; index < length; index++) {\n if (stopped) break;\n var _handlers = priorities[list[index]];\n // in case if all handlers of priority were removed while event\n // was dispatched and handlers become undefined.\n if (_handlers) {\n var _runner = this.createRunner(_handlers, stopPropagation);\n _runner.run(event, target);\n if (_runner.immediatelyStopped) break;\n }\n }\n }\n }\n }]);\n\n return EventListeners;\n}();\n\nvar EventDispatcher = function () {\n function EventDispatcher() {\n var eventPreprocessor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n var noInit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\n _classCallCheck(this, EventDispatcher);\n\n if (!noInit) {\n this.initialize(eventPreprocessor);\n }\n }\n\n /**\r\n * @private\r\n */\n\n\n _createClass(EventDispatcher, [{\n key: 'initialize',\n value: function initialize() {\n var eventPreprocessor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\n this._eventPreprocessor = eventPreprocessor;\n this._listeners = new EventListeners();\n }\n }, {\n key: 'addEventListener',\n value: function addEventListener(eventType, listener) {\n var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n\n this._listeners.add(eventType, listener, -priority || 0);\n }\n }, {\n key: 'hasEventListener',\n value: function hasEventListener(eventType) {\n return this._listeners.has(eventType);\n }\n }, {\n key: 'removeEventListener',\n value: function removeEventListener(eventType, listener) {\n this._listeners.remove(eventType, listener);\n }\n }, {\n key: 'removeAllEventListeners',\n value: function removeAllEventListeners(eventType) {\n this._listeners.removeAll(eventType);\n }\n }, {\n key: 'dispatchEvent',\n value: function dispatchEvent(event, data) {\n var eventObject = EventDispatcher.getEvent(event, data);\n if (this._eventPreprocessor) {\n eventObject = this._eventPreprocessor.call(this, eventObject);\n }\n this._listeners.call(eventObject);\n }\n }], [{\n key: 'isObject',\n value: function isObject(value) {\n return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;\n }\n }, {\n key: 'getEvent',\n value: function getEvent(eventOrType, optionalData) {\n var event = eventOrType;\n if (!EventDispatcher.isObject(eventOrType)) {\n event = new EventDispatcher.Event(String(eventOrType), optionalData);\n }\n return event;\n }\n }, {\n key: 'create',\n value: function create(eventPreprocessor) {\n return new EventDispatcher(eventPreprocessor);\n }\n\n /* eslint no-undef: \"off\" */\n\n }]);\n\n return EventDispatcher;\n}();\n\nEventDispatcher.Event = Event;\n\nexports.default = EventDispatcher;\n\n/***/ })\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// event-dispatcher.direct.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"http://localhost:8081/dist/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 838017a37f7a653c0fde","import EventDispatcher from './EventDispatcher';\n\nmodule.exports = EventDispatcher;\n\n\n\n// WEBPACK FOOTER //\n// ./source/direct.js","/**\r\n * Created by Oleg Galaburda on 09.02.16.\r\n * @flow\r\n */\r\n\r\nimport type {\r\n EventObject,\r\n EventType,\r\n EventListener,\r\n EventProcessor,\r\n IEvent,\r\n IEventDispatcher,\r\n} from './TypeDefinition';\r\n\r\nconst hasOwnProp = (target: any, name: string): boolean => (\r\n Object.prototype.hasOwnProperty.call(target, name)\r\n);\r\n\r\nexport class Event implements IEvent {\r\n\r\n type: string;\r\n data: mixed;\r\n defaultPrevented: boolean;\r\n stopPropagation: ?() => void;\r\n stopImmediatePropagation: ?() => void;\r\n\r\n constructor(type: string, data: mixed = null) {\r\n this.type = type;\r\n this.data = data;\r\n this.defaultPrevented = false;\r\n }\r\n\r\n toJSON(): EventObject {\r\n return { type: this.type, data: this.data };\r\n }\r\n\r\n isDefaultPrevented(): boolean {\r\n return this.defaultPrevented;\r\n }\r\n\r\n preventDefault() {\r\n this.defaultPrevented = true;\r\n }\r\n}\r\n\r\ntype EventPrioritiesCollection = {\r\n [priority: string]: Array;\r\n}\r\n\r\ntype EventTypesCollection = {\r\n [eventType: string]: EventPrioritiesCollection;\r\n}\r\n\r\nclass ListenersRunner {\r\n index: number = -1;\r\n immediatelyStopped: boolean = false;\r\n listeners: EventListener[];\r\n onStopped: (runner: ListenersRunner) => void;\r\n onComplete: (runner: ListenersRunner) => void;\r\n\r\n constructor(\r\n listeners: EventListener[],\r\n onStopped: (runner: ListenersRunner) => void,\r\n onComplete: (runner: ListenersRunner) => void,\r\n ) {\r\n this.listeners = listeners;\r\n this.onStopped = onStopped;\r\n this.onComplete = onComplete;\r\n }\r\n\r\n stopImmediatePropagation = () => {\r\n this.immediatelyStopped = true;\r\n };\r\n\r\n run(event: EventObject, target: any) {\r\n let listener: EventListener;\r\n const { listeners } = this;\r\n this.augmentEvent(event);\r\n // TODO this has to be handled in separate object ListenersRunner that should be\r\n // created for each call() call and asked for index validation on each listener remove.\r\n for (this.index = 0; this.index < listeners.length; this.index++) {\r\n if (this.immediatelyStopped) break;\r\n listener = listeners[this.index];\r\n listener.call(target, event);\r\n }\r\n this.clearEvent(event);\r\n this.onComplete(this);\r\n }\r\n\r\n augmentEvent(eventObject: EventObject) {\r\n const event: EventObject = eventObject;\r\n event.stopPropagation = this.onStopped;\r\n event.stopImmediatePropagation = this.stopImmediatePropagation;\r\n }\r\n\r\n /* eslint class-methods-use-this: \"off\" */\r\n clearEvent(eventObject: EventObject) {\r\n const event: EventObject = eventObject;\r\n delete event.stopPropagation;\r\n delete event.stopImmediatePropagation;\r\n }\r\n\r\n listenerRemoved(listeners: EventListener[], index: number) {\r\n if (listeners === this.listeners && index <= this.index) {\r\n this.index--;\r\n }\r\n }\r\n}\r\n\r\nclass EventListeners {\r\n /**\r\n * key - event Type\r\n * value - hash of priorities\r\n * key - priority\r\n * value - list of handlers\r\n * @type {Object>>}\r\n * @private\r\n */\r\n _listeners: EventTypesCollection = {};\r\n _runners: ListenersRunner[] = [];\r\n\r\n createList(eventType: string, priorityOpt?: mixed): Array {\r\n const priority: number = parseInt(priorityOpt, 10);\r\n const target: EventPrioritiesCollection = this.getPrioritiesByKey(eventType);\r\n const key: string = String(priority);\r\n let value: Array;\r\n if (hasOwnProp(target, key)) {\r\n value = target[key];\r\n } else {\r\n value = [];\r\n target[key] = value;\r\n }\r\n return value;\r\n }\r\n\r\n getPrioritiesByKey(key: string): EventPrioritiesCollection {\r\n let value: EventPrioritiesCollection;\r\n if (hasOwnProp(this._listeners, key)) {\r\n value = this._listeners[key];\r\n } else {\r\n value = {};\r\n this._listeners[key] = value;\r\n }\r\n return value;\r\n }\r\n\r\n add(eventType: string, handler: EventListener, priority: number) {\r\n const handlers = this.createList(eventType, priority);\r\n if (handlers.indexOf(handler) < 0) {\r\n handlers.push(handler);\r\n }\r\n }\r\n\r\n has(eventType: string): boolean {\r\n let priority: string;\r\n let result = false;\r\n const priorities = this.getPrioritiesByKey(eventType);\r\n if (priorities) {\r\n for (priority in priorities) {\r\n if (hasOwnProp(priorities, priority)) {\r\n result = true;\r\n break;\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n remove(eventType: string, handler) {\r\n const priorities = this.getPrioritiesByKey(eventType);\r\n if (priorities) {\r\n const list = Object.getOwnPropertyNames(priorities);\r\n const { length } = list;\r\n for (let index = 0; index < length; index++) {\r\n const priority = list[index];\r\n const handlers = priorities[priority];\r\n const handlerIndex = handlers.indexOf(handler);\r\n if (handlerIndex >= 0) {\r\n handlers.splice(handlerIndex, 1);\r\n if (!handlers.length) {\r\n delete priorities[priority];\r\n }\r\n this._runners.forEach((runner) => {\r\n runner.listenerRemoved(handlers, handlerIndex);\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n removeAll(eventType: string) {\r\n delete this._listeners[eventType];\r\n }\r\n\r\n createRunner(handlers, onStopped) {\r\n const runner = new ListenersRunner(handlers, onStopped, this.removeRunner);\r\n this._runners.push(runner);\r\n return runner;\r\n }\r\n\r\n removeRunner = (runner) => {\r\n this._runners.splice(this._runners.indexOf(runner), 1);\r\n };\r\n\r\n call(event: EventObject, target: any) {\r\n const priorities = this.getPrioritiesByKey(event.type);\r\n let stopped = false;\r\n const stopPropagation = () => {\r\n stopped = true;\r\n };\r\n if (priorities) {\r\n // getOwnPropertyNames() or keys()?\r\n const list: string[] = Object\r\n .getOwnPropertyNames(priorities)\r\n .sort((a: any, b: any) => (a - b));\r\n const { length } = list;\r\n for (let index = 0; index < length; index++) {\r\n if (stopped) break;\r\n const handlers: Array = priorities[list[index]];\r\n // in case if all handlers of priority were removed while event\r\n // was dispatched and handlers become undefined.\r\n if (handlers) {\r\n const runner = this.createRunner(handlers, stopPropagation);\r\n runner.run(event, target);\r\n if (runner.immediatelyStopped) break;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nclass EventDispatcher implements IEventDispatcher {\r\n\r\n _listeners: EventListeners;\r\n _eventPreprocessor: EventProcessor;\r\n\r\n constructor(eventPreprocessor: EventProcessor = null, noInit: boolean = false) {\r\n if (!noInit) {\r\n this.initialize(eventPreprocessor);\r\n }\r\n }\r\n\r\n /**\r\n * @private\r\n */\r\n initialize(eventPreprocessor: EventProcessor = null) {\r\n this._eventPreprocessor = eventPreprocessor;\r\n this._listeners = new EventListeners();\r\n }\r\n\r\n addEventListener(eventType: string, listener: EventListener, priority: number = 0) {\r\n this._listeners.add(eventType, listener, -priority || 0);\r\n }\r\n\r\n hasEventListener(eventType: string) {\r\n return this._listeners.has(eventType);\r\n }\r\n\r\n removeEventListener(eventType: string, listener: EventListener) {\r\n this._listeners.remove(eventType, listener);\r\n }\r\n\r\n removeAllEventListeners(eventType: string) {\r\n this._listeners.removeAll(eventType);\r\n }\r\n\r\n dispatchEvent(event: EventType, data: mixed) {\r\n let eventObject = EventDispatcher.getEvent(event, data);\r\n if (this._eventPreprocessor) {\r\n eventObject = this._eventPreprocessor.call(this, eventObject);\r\n }\r\n this._listeners.call(eventObject);\r\n }\r\n\r\n static isObject(value: mixed) {\r\n return (typeof value === 'object') && (value !== null);\r\n }\r\n\r\n static getEvent(eventOrType: EventType, optionalData: mixed): EventObject {\r\n let event = eventOrType;\r\n if (!EventDispatcher.isObject(eventOrType)) {\r\n event = new EventDispatcher.Event(String(eventOrType), optionalData);\r\n }\r\n return (event: any);\r\n }\r\n\r\n static create(eventPreprocessor: EventProcessor) {\r\n return new EventDispatcher(eventPreprocessor);\r\n }\r\n\r\n /* eslint no-undef: \"off\" */\r\n static Event: Class;\r\n}\r\n\r\nEventDispatcher.Event = Event;\r\n\r\nexport default EventDispatcher;\r\n\n\n\n// WEBPACK FOOTER //\n// ./source/EventDispatcher.js"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/event-dispatcher.js b/dist/event-dispatcher.js index 9c06587..e695f20 100644 --- a/dist/event-dispatcher.js +++ b/dist/event-dispatcher.js @@ -119,11 +119,13 @@ var hasOwnProp = function hasOwnProp(target, name) { */ var Event = exports.Event = function () { - function Event(type, data) { + function Event(type) { + var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + _classCallCheck(this, Event); this.type = type; - this.data = data || null; + this.data = data; this.defaultPrevented = false; } @@ -361,7 +363,8 @@ var EventListeners = function () { }(); var EventDispatcher = function () { - function EventDispatcher(eventPreprocessor) { + function EventDispatcher() { + var eventPreprocessor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var noInit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; _classCallCheck(this, EventDispatcher); @@ -378,7 +381,9 @@ var EventDispatcher = function () { _createClass(EventDispatcher, [{ key: 'initialize', - value: function initialize(eventPreprocessor) { + value: function initialize() { + var eventPreprocessor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + this._eventPreprocessor = eventPreprocessor; this._listeners = new EventListeners(); } diff --git a/dist/event-dispatcher.js.map b/dist/event-dispatcher.js.map index 221b34c..0eebe9a 100644 --- a/dist/event-dispatcher.js.map +++ b/dist/event-dispatcher.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap db93486fe7f834e90e94","webpack:///./source/index.js","webpack:///./source/EventDispatcher.js"],"names":["Event","hasOwnProp","target","name","Object","prototype","hasOwnProperty","call","type","data","defaultPrevented","ListenersRunner","listeners","onStopped","onComplete","index","immediatelyStopped","stopImmediatePropagation","event","listener","augmentEvent","length","clearEvent","eventObject","stopPropagation","EventListeners","_listeners","_runners","removeRunner","runner","splice","indexOf","eventType","priorityOpt","priority","parseInt","getPrioritiesByKey","key","String","value","handler","handlers","createList","push","result","priorities","list","getOwnPropertyNames","handlerIndex","forEach","listenerRemoved","stopped","sort","a","b","createRunner","run","EventDispatcher","eventPreprocessor","noInit","initialize","_eventPreprocessor","add","has","remove","removeAll","getEvent","eventOrType","optionalData","isObject"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yC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;AACD;AACD,WAAKG,UAAL,CAAgBnB,IAAhB,CAAqBgB,WAArB;AACD;;;6BAEegB,K,EAAc;AAC5B,aAAQ,QAAOA,KAAP,yCAAOA,KAAP,OAAiB,QAAlB,IAAgCA,UAAU,IAAjD;AACD;;;6BAEe4B,W,EAAwBC,Y,EAAkC;AACxE,UAAIlD,QAAQiD,WAAZ;AACA,UAAI,CAACV,gBAAgBY,QAAhB,CAAyBF,WAAzB,CAAL,EAA4C;AAC1CjD,gBAAQ,IAAIuC,gBAAgBzD,KAApB,CAA0BsC,OAAO6B,WAAP,CAA1B,EAA+CC,YAA/C,CAAR;AACD;AACD,aAAQlD,KAAR;AACD;;;2BAEawC,iB,EAAmC;AAC/C,aAAO,IAAID,eAAJ,CAAoBC,iBAApB,CAAP;AACD;;AAED;;;;;;;AAIFD,gBAAgBzD,KAAhB,GAAwBA,KAAxB;;kBAEeyD,e","file":"event-dispatcher.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"EventDispatcher\"] = factory();\n\telse\n\t\troot[\"EventDispatcher\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"http://localhost:8081/dist/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap db93486fe7f834e90e94","import EventDispatcher, { Event } from './EventDispatcher';\n\nexport default EventDispatcher;\nexport { Event };\n\n\n\n// WEBPACK FOOTER //\n// ./source/index.js","/**\n * Created by Oleg Galaburda on 09.02.16.\n * @flow\n */\n\nimport type {\n EventObject,\n EventType,\n EventListener,\n EventProcessor,\n IEvent,\n IEventDispatcher,\n} from './TypeDefinition';\n\nconst hasOwnProp = (target: any, name: string): boolean => (\n Object.prototype.hasOwnProperty.call(target, name)\n);\n\nexport class Event implements IEvent {\n\n type: string;\n data: mixed;\n defaultPrevented: boolean;\n stopPropagation: ?() => void;\n stopImmediatePropagation: ?() => void;\n\n constructor(type: string, data: mixed) {\n this.type = type;\n this.data = data || null;\n this.defaultPrevented = false;\n }\n\n toJSON(): EventObject {\n return { type: this.type, data: this.data };\n }\n\n isDefaultPrevented(): boolean {\n return this.defaultPrevented;\n }\n\n preventDefault() {\n this.defaultPrevented = true;\n }\n}\n\ntype EventPrioritiesCollection = {\n [priority: string]: Array;\n}\n\ntype EventTypesCollection = {\n [eventType: string]: EventPrioritiesCollection;\n}\n\nclass ListenersRunner {\n index: number = -1;\n immediatelyStopped: boolean = false;\n listeners: EventListener[];\n onStopped: (runner: ListenersRunner) => void;\n onComplete: (runner: ListenersRunner) => void;\n\n constructor(\n listeners: EventListener[],\n onStopped: (runner: ListenersRunner) => void,\n onComplete: (runner: ListenersRunner) => void,\n ) {\n this.listeners = listeners;\n this.onStopped = onStopped;\n this.onComplete = onComplete;\n }\n\n stopImmediatePropagation = () => {\n this.immediatelyStopped = true;\n };\n\n run(event: EventObject, target: any) {\n let listener: EventListener;\n const { listeners } = this;\n this.augmentEvent(event);\n // TODO this has to be handled in separate object ListenersRunner that should be\n // created for each call() call and asked for index validation on each listener remove.\n for (this.index = 0; this.index < listeners.length; this.index++) {\n if (this.immediatelyStopped) break;\n listener = listeners[this.index];\n listener.call(target, event);\n }\n this.clearEvent(event);\n this.onComplete(this);\n }\n\n augmentEvent(eventObject: EventObject) {\n const event: EventObject = eventObject;\n event.stopPropagation = this.onStopped;\n event.stopImmediatePropagation = this.stopImmediatePropagation;\n }\n\n /* eslint class-methods-use-this: \"off\" */\n clearEvent(eventObject: EventObject) {\n const event: EventObject = eventObject;\n delete event.stopPropagation;\n delete event.stopImmediatePropagation;\n }\n\n listenerRemoved(listeners: EventListener[], index: number) {\n if (listeners === this.listeners && index <= this.index) {\n this.index--;\n }\n }\n}\n\nclass EventListeners {\n /**\n * key - event Type\n * value - hash of priorities\n * key - priority\n * value - list of handlers\n * @type {Object>>}\n * @private\n */\n _listeners: EventTypesCollection = {};\n _runners: ListenersRunner[] = [];\n\n createList(eventType: string, priorityOpt?: mixed): Array {\n const priority: number = parseInt(priorityOpt, 10);\n const target: EventPrioritiesCollection = this.getPrioritiesByKey(eventType);\n const key: string = String(priority);\n let value: Array;\n if (hasOwnProp(target, key)) {\n value = target[key];\n } else {\n value = [];\n target[key] = value;\n }\n return value;\n }\n\n getPrioritiesByKey(key: string): EventPrioritiesCollection {\n let value: EventPrioritiesCollection;\n if (hasOwnProp(this._listeners, key)) {\n value = this._listeners[key];\n } else {\n value = {};\n this._listeners[key] = value;\n }\n return value;\n }\n\n add(eventType: string, handler: EventListener, priority: number) {\n const handlers = this.createList(eventType, priority);\n if (handlers.indexOf(handler) < 0) {\n handlers.push(handler);\n }\n }\n\n has(eventType: string): boolean {\n let priority: string;\n let result = false;\n const priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n for (priority in priorities) {\n if (hasOwnProp(priorities, priority)) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n remove(eventType: string, handler) {\n const priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n const list = Object.getOwnPropertyNames(priorities);\n const { length } = list;\n for (let index = 0; index < length; index++) {\n const priority = list[index];\n const handlers = priorities[priority];\n const handlerIndex = handlers.indexOf(handler);\n if (handlerIndex >= 0) {\n handlers.splice(handlerIndex, 1);\n if (!handlers.length) {\n delete priorities[priority];\n }\n this._runners.forEach((runner) => {\n runner.listenerRemoved(handlers, handlerIndex);\n });\n }\n }\n }\n }\n\n removeAll(eventType: string) {\n delete this._listeners[eventType];\n }\n\n createRunner(handlers, onStopped) {\n const runner = new ListenersRunner(handlers, onStopped, this.removeRunner);\n this._runners.push(runner);\n return runner;\n }\n\n removeRunner = (runner) => {\n this._runners.splice(this._runners.indexOf(runner), 1);\n };\n\n call(event: EventObject, target: any) {\n const priorities = this.getPrioritiesByKey(event.type);\n let stopped = false;\n const stopPropagation = () => {\n stopped = true;\n };\n if (priorities) {\n // getOwnPropertyNames() or keys()?\n const list: string[] = Object\n .getOwnPropertyNames(priorities)\n .sort((a: any, b: any) => (a - b));\n const { length } = list;\n for (let index = 0; index < length; index++) {\n if (stopped) break;\n const handlers: Array = priorities[list[index]];\n // in case if all handlers of priority were removed while event\n // was dispatched and handlers become undefined.\n if (handlers) {\n const runner = this.createRunner(handlers, stopPropagation);\n runner.run(event, target);\n if (runner.immediatelyStopped) break;\n }\n }\n }\n }\n}\n\nclass EventDispatcher implements IEventDispatcher {\n\n _listeners: EventListeners;\n _eventPreprocessor: EventProcessor;\n\n constructor(eventPreprocessor: EventProcessor, noInit: boolean = false) {\n if (!noInit) {\n this.initialize(eventPreprocessor);\n }\n }\n\n /**\n * @private\n */\n initialize(eventPreprocessor: EventProcessor) {\n this._eventPreprocessor = eventPreprocessor;\n this._listeners = new EventListeners();\n }\n\n addEventListener(eventType: string, listener: EventListener, priority: number = 0) {\n this._listeners.add(eventType, listener, -priority || 0);\n }\n\n hasEventListener(eventType: string) {\n return this._listeners.has(eventType);\n }\n\n removeEventListener(eventType: string, listener: EventListener) {\n this._listeners.remove(eventType, listener);\n }\n\n removeAllEventListeners(eventType: string) {\n this._listeners.removeAll(eventType);\n }\n\n dispatchEvent(event: EventType, data: mixed) {\n let eventObject = EventDispatcher.getEvent(event, data);\n if (this._eventPreprocessor) {\n eventObject = this._eventPreprocessor.call(this, eventObject);\n }\n this._listeners.call(eventObject);\n }\n\n static isObject(value: mixed) {\n return (typeof value === 'object') && (value !== null);\n }\n\n static getEvent(eventOrType: EventType, optionalData: mixed): EventObject {\n let event = eventOrType;\n if (!EventDispatcher.isObject(eventOrType)) {\n event = new EventDispatcher.Event(String(eventOrType), optionalData);\n }\n return (event: any);\n }\n\n static create(eventPreprocessor: EventProcessor) {\n return new EventDispatcher(eventPreprocessor);\n }\n\n /* eslint no-undef: \"off\" */\n static Event: Class;\n}\n\nEventDispatcher.Event = Event;\n\nexport default EventDispatcher;\n\n\n\n// WEBPACK FOOTER //\n// ./source/EventDispatcher.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 10858de3bdd70b6dc47a","webpack:///./source/index.js","webpack:///./source/EventDispatcher.js"],"names":["Event","hasOwnProp","target","name","Object","prototype","hasOwnProperty","call","type","data","defaultPrevented","ListenersRunner","listeners","onStopped","onComplete","index","immediatelyStopped","stopImmediatePropagation","event","listener","augmentEvent","length","clearEvent","eventObject","stopPropagation","EventListeners","_listeners","_runners","removeRunner","runner","splice","indexOf","eventType","priorityOpt","priority","parseInt","getPrioritiesByKey","key","String","value","handler","handlers","createList","push","result","priorities","list","getOwnPropertyNames","handlerIndex","forEach","listenerRemoved","stopped","sort","a","b","createRunner","run","EventDispatcher","eventPreprocessor","noInit","initialize","_eventPreprocessor","add","has","remove","removeAll","getEvent","eventOrType","optionalData","isObject"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;AC7DA;;;;;;;QAGSA,K;;;;;;;;;;;;;;;;;;;ACWT,IAAMC,aAAa,SAAbA,UAAa,CAACC,MAAD,EAAcC,IAAd;AAAA,SACjBC,OAAOC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCL,MAArC,EAA6CC,IAA7C,CADiB;AAAA,CAAnB,C,CAdA;;;;;IAkBaH,K,WAAAA,K;AAQX,iBAAYQ,IAAZ,EAA8C;AAAA,QAApBC,IAAoB,uEAAN,IAAM;;AAAA;;AAC5C,SAAKD,IAAL,GAAYA,IAAZ;AACA,SAAKC,IAAL,GAAYA,IAAZ;AACA,SAAKC,gBAAL,GAAwB,KAAxB;AACD;;;;6BAEqB;AACpB,aAAO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CAAP;AACD;;AAED;;;;;;;AAIFD,gBAAgBzD,KAAhB,GAAwBA,KAAxB;;kBAEeyD,e","file":"event-dispatcher.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"EventDispatcher\"] = factory();\n\telse\n\t\troot[\"EventDispatcher\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"http://localhost:8081/dist/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 10858de3bdd70b6dc47a","import EventDispatcher, { Event } from './EventDispatcher';\n\nexport default EventDispatcher;\nexport { Event };\n\n\n\n// WEBPACK FOOTER //\n// ./source/index.js","/**\r\n * Created by Oleg Galaburda on 09.02.16.\r\n * @flow\r\n */\r\n\r\nimport type {\r\n EventObject,\r\n EventType,\r\n EventListener,\r\n EventProcessor,\r\n IEvent,\r\n IEventDispatcher,\r\n} from './TypeDefinition';\r\n\r\nconst hasOwnProp = (target: any, name: string): boolean => (\r\n Object.prototype.hasOwnProperty.call(target, name)\r\n);\r\n\r\nexport class Event implements IEvent {\r\n\r\n type: string;\r\n data: mixed;\r\n defaultPrevented: boolean;\r\n stopPropagation: ?() => void;\r\n stopImmediatePropagation: ?() => void;\r\n\r\n constructor(type: string, data: mixed = null) {\r\n this.type = type;\r\n this.data = data;\r\n this.defaultPrevented = false;\r\n }\r\n\r\n toJSON(): EventObject {\r\n return { type: this.type, data: this.data };\r\n }\r\n\r\n isDefaultPrevented(): boolean {\r\n return this.defaultPrevented;\r\n }\r\n\r\n preventDefault() {\r\n this.defaultPrevented = true;\r\n }\r\n}\r\n\r\ntype EventPrioritiesCollection = {\r\n [priority: string]: Array;\r\n}\r\n\r\ntype EventTypesCollection = {\r\n [eventType: string]: EventPrioritiesCollection;\r\n}\r\n\r\nclass ListenersRunner {\r\n index: number = -1;\r\n immediatelyStopped: boolean = false;\r\n listeners: EventListener[];\r\n onStopped: (runner: ListenersRunner) => void;\r\n onComplete: (runner: ListenersRunner) => void;\r\n\r\n constructor(\r\n listeners: EventListener[],\r\n onStopped: (runner: ListenersRunner) => void,\r\n onComplete: (runner: ListenersRunner) => void,\r\n ) {\r\n this.listeners = listeners;\r\n this.onStopped = onStopped;\r\n this.onComplete = onComplete;\r\n }\r\n\r\n stopImmediatePropagation = () => {\r\n this.immediatelyStopped = true;\r\n };\r\n\r\n run(event: EventObject, target: any) {\r\n let listener: EventListener;\r\n const { listeners } = this;\r\n this.augmentEvent(event);\r\n // TODO this has to be handled in separate object ListenersRunner that should be\r\n // created for each call() call and asked for index validation on each listener remove.\r\n for (this.index = 0; this.index < listeners.length; this.index++) {\r\n if (this.immediatelyStopped) break;\r\n listener = listeners[this.index];\r\n listener.call(target, event);\r\n }\r\n this.clearEvent(event);\r\n this.onComplete(this);\r\n }\r\n\r\n augmentEvent(eventObject: EventObject) {\r\n const event: EventObject = eventObject;\r\n event.stopPropagation = this.onStopped;\r\n event.stopImmediatePropagation = this.stopImmediatePropagation;\r\n }\r\n\r\n /* eslint class-methods-use-this: \"off\" */\r\n clearEvent(eventObject: EventObject) {\r\n const event: EventObject = eventObject;\r\n delete event.stopPropagation;\r\n delete event.stopImmediatePropagation;\r\n }\r\n\r\n listenerRemoved(listeners: EventListener[], index: number) {\r\n if (listeners === this.listeners && index <= this.index) {\r\n this.index--;\r\n }\r\n }\r\n}\r\n\r\nclass EventListeners {\r\n /**\r\n * key - event Type\r\n * value - hash of priorities\r\n * key - priority\r\n * value - list of handlers\r\n * @type {Object>>}\r\n * @private\r\n */\r\n _listeners: EventTypesCollection = {};\r\n _runners: ListenersRunner[] = [];\r\n\r\n createList(eventType: string, priorityOpt?: mixed): Array {\r\n const priority: number = parseInt(priorityOpt, 10);\r\n const target: EventPrioritiesCollection = this.getPrioritiesByKey(eventType);\r\n const key: string = String(priority);\r\n let value: Array;\r\n if (hasOwnProp(target, key)) {\r\n value = target[key];\r\n } else {\r\n value = [];\r\n target[key] = value;\r\n }\r\n return value;\r\n }\r\n\r\n getPrioritiesByKey(key: string): EventPrioritiesCollection {\r\n let value: EventPrioritiesCollection;\r\n if (hasOwnProp(this._listeners, key)) {\r\n value = this._listeners[key];\r\n } else {\r\n value = {};\r\n this._listeners[key] = value;\r\n }\r\n return value;\r\n }\r\n\r\n add(eventType: string, handler: EventListener, priority: number) {\r\n const handlers = this.createList(eventType, priority);\r\n if (handlers.indexOf(handler) < 0) {\r\n handlers.push(handler);\r\n }\r\n }\r\n\r\n has(eventType: string): boolean {\r\n let priority: string;\r\n let result = false;\r\n const priorities = this.getPrioritiesByKey(eventType);\r\n if (priorities) {\r\n for (priority in priorities) {\r\n if (hasOwnProp(priorities, priority)) {\r\n result = true;\r\n break;\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n remove(eventType: string, handler) {\r\n const priorities = this.getPrioritiesByKey(eventType);\r\n if (priorities) {\r\n const list = Object.getOwnPropertyNames(priorities);\r\n const { length } = list;\r\n for (let index = 0; index < length; index++) {\r\n const priority = list[index];\r\n const handlers = priorities[priority];\r\n const handlerIndex = handlers.indexOf(handler);\r\n if (handlerIndex >= 0) {\r\n handlers.splice(handlerIndex, 1);\r\n if (!handlers.length) {\r\n delete priorities[priority];\r\n }\r\n this._runners.forEach((runner) => {\r\n runner.listenerRemoved(handlers, handlerIndex);\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n removeAll(eventType: string) {\r\n delete this._listeners[eventType];\r\n }\r\n\r\n createRunner(handlers, onStopped) {\r\n const runner = new ListenersRunner(handlers, onStopped, this.removeRunner);\r\n this._runners.push(runner);\r\n return runner;\r\n }\r\n\r\n removeRunner = (runner) => {\r\n this._runners.splice(this._runners.indexOf(runner), 1);\r\n };\r\n\r\n call(event: EventObject, target: any) {\r\n const priorities = this.getPrioritiesByKey(event.type);\r\n let stopped = false;\r\n const stopPropagation = () => {\r\n stopped = true;\r\n };\r\n if (priorities) {\r\n // getOwnPropertyNames() or keys()?\r\n const list: string[] = Object\r\n .getOwnPropertyNames(priorities)\r\n .sort((a: any, b: any) => (a - b));\r\n const { length } = list;\r\n for (let index = 0; index < length; index++) {\r\n if (stopped) break;\r\n const handlers: Array = priorities[list[index]];\r\n // in case if all handlers of priority were removed while event\r\n // was dispatched and handlers become undefined.\r\n if (handlers) {\r\n const runner = this.createRunner(handlers, stopPropagation);\r\n runner.run(event, target);\r\n if (runner.immediatelyStopped) break;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nclass EventDispatcher implements IEventDispatcher {\r\n\r\n _listeners: EventListeners;\r\n _eventPreprocessor: EventProcessor;\r\n\r\n constructor(eventPreprocessor: EventProcessor = null, noInit: boolean = false) {\r\n if (!noInit) {\r\n this.initialize(eventPreprocessor);\r\n }\r\n }\r\n\r\n /**\r\n * @private\r\n */\r\n initialize(eventPreprocessor: EventProcessor = null) {\r\n this._eventPreprocessor = eventPreprocessor;\r\n this._listeners = new EventListeners();\r\n }\r\n\r\n addEventListener(eventType: string, listener: EventListener, priority: number = 0) {\r\n this._listeners.add(eventType, listener, -priority || 0);\r\n }\r\n\r\n hasEventListener(eventType: string) {\r\n return this._listeners.has(eventType);\r\n }\r\n\r\n removeEventListener(eventType: string, listener: EventListener) {\r\n this._listeners.remove(eventType, listener);\r\n }\r\n\r\n removeAllEventListeners(eventType: string) {\r\n this._listeners.removeAll(eventType);\r\n }\r\n\r\n dispatchEvent(event: EventType, data: mixed) {\r\n let eventObject = EventDispatcher.getEvent(event, data);\r\n if (this._eventPreprocessor) {\r\n eventObject = this._eventPreprocessor.call(this, eventObject);\r\n }\r\n this._listeners.call(eventObject);\r\n }\r\n\r\n static isObject(value: mixed) {\r\n return (typeof value === 'object') && (value !== null);\r\n }\r\n\r\n static getEvent(eventOrType: EventType, optionalData: mixed): EventObject {\r\n let event = eventOrType;\r\n if (!EventDispatcher.isObject(eventOrType)) {\r\n event = new EventDispatcher.Event(String(eventOrType), optionalData);\r\n }\r\n return (event: any);\r\n }\r\n\r\n static create(eventPreprocessor: EventProcessor) {\r\n return new EventDispatcher(eventPreprocessor);\r\n }\r\n\r\n /* eslint no-undef: \"off\" */\r\n static Event: Class;\r\n}\r\n\r\nEventDispatcher.Event = Event;\r\n\r\nexport default EventDispatcher;\r\n\n\n\n// WEBPACK FOOTER //\n// ./source/EventDispatcher.js"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/event-dispatcher.min.js b/dist/event-dispatcher.min.js index 6b7490b..fb9895b 100644 --- a/dist/event-dispatcher.min.js +++ b/dist/event-dispatcher.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EventDispatcher=t():e.EventDispatcher=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="http://localhost:8081/dist/",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Event=void 0;var i=n(1),r=function(e){return e&&e.__esModule?e:{default:e}}(i);t.default=r.default,t.Event=i.Event},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n=0&&(s.splice(u,1),s.length||delete i[o],n._runners.forEach(function(e){e.listenerRemoved(s,u)}))}(s)}},{key:"removeAll",value:function(e){delete this._listeners[e]}},{key:"createRunner",value:function(e,t){var n=new a(e,t,this.removeRunner);return this._runners.push(n),n}},{key:"call",value:function(e,t){var n=this.getPrioritiesByKey(e.type),i=!1,r=function(){i=!0};if(n)for(var o=Object.getOwnPropertyNames(n).sort(function(e,t){return e-t}),s=o.length,u=0;u1&&void 0!==arguments[1]&&arguments[1];i(this,e),n||this.initialize(t)}return o(e,[{key:"initialize",value:function(e){this._eventPreprocessor=e,this._listeners=new l}},{key:"addEventListener",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this._listeners.add(e,t,-n||0)}},{key:"hasEventListener",value:function(e){return this._listeners.has(e)}},{key:"removeEventListener",value:function(e,t){this._listeners.remove(e,t)}},{key:"removeAllEventListeners",value:function(e){this._listeners.removeAll(e)}},{key:"dispatchEvent",value:function(t,n){var i=e.getEvent(t,n);this._eventPreprocessor&&(i=this._eventPreprocessor.call(this,i)),this._listeners.call(i)}}],[{key:"isObject",value:function(e){return"object"===(void 0===e?"undefined":r(e))&&null!==e}},{key:"getEvent",value:function(t,n){var i=t;return e.isObject(t)||(i=new e.Event(String(t),n)),i}},{key:"create",value:function(t){return new e(t)}}]),e}();c.Event=u,t.default=c}])}); +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EventDispatcher=t():e.EventDispatcher=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="http://localhost:8081/dist/",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Event=void 0;var i=n(1),r=function(e){return e&&e.__esModule?e:{default:e}}(i);t.default=r.default,t.Event=i.Event},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:null;i(this,e),this.type=t,this.data=n,this.defaultPrevented=!1}return o(e,[{key:"toJSON",value:function(){return{type:this.type,data:this.data}}},{key:"isDefaultPrevented",value:function(){return this.defaultPrevented}},{key:"preventDefault",value:function(){this.defaultPrevented=!0}}]),e}(),a=function(){function e(t,n,r){var o=this;i(this,e),this.index=-1,this.immediatelyStopped=!1,this.stopImmediatePropagation=function(){o.immediatelyStopped=!0},this.listeners=t,this.onStopped=n,this.onComplete=r}return o(e,[{key:"run",value:function(e,t){var n=void 0,i=this.listeners;for(this.augmentEvent(e),this.index=0;this.index=0&&(s.splice(u,1),s.length||delete i[o],n._runners.forEach(function(e){e.listenerRemoved(s,u)}))}(s)}},{key:"removeAll",value:function(e){delete this._listeners[e]}},{key:"createRunner",value:function(e,t){var n=new a(e,t,this.removeRunner);return this._runners.push(n),n}},{key:"call",value:function(e,t){var n=this.getPrioritiesByKey(e.type),i=!1,r=function(){i=!0};if(n)for(var o=Object.getOwnPropertyNames(n).sort(function(e,t){return e-t}),s=o.length,u=0;u0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i(this,e),n||this.initialize(t)}return o(e,[{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._eventPreprocessor=e,this._listeners=new l}},{key:"addEventListener",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this._listeners.add(e,t,-n||0)}},{key:"hasEventListener",value:function(e){return this._listeners.has(e)}},{key:"removeEventListener",value:function(e,t){this._listeners.remove(e,t)}},{key:"removeAllEventListeners",value:function(e){this._listeners.removeAll(e)}},{key:"dispatchEvent",value:function(t,n){var i=e.getEvent(t,n);this._eventPreprocessor&&(i=this._eventPreprocessor.call(this,i)),this._listeners.call(i)}}],[{key:"isObject",value:function(e){return"object"===(void 0===e?"undefined":r(e))&&null!==e}},{key:"getEvent",value:function(t,n){var i=t;return e.isObject(t)||(i=new e.Event(String(t),n)),i}},{key:"create",value:function(t){return new e(t)}}]),e}();c.Event=u,t.default=c}])}); //# sourceMappingURL=event-dispatcher.min.js.map \ No newline at end of file diff --git a/dist/event-dispatcher.min.js.map b/dist/event-dispatcher.min.js.map index 9d302c2..1d45aec 100644 --- a/dist/event-dispatcher.min.js.map +++ b/dist/event-dispatcher.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///event-dispatcher.min.js","webpack:///webpack/bootstrap 756d1bc428259c6e1a11","webpack:///./source/index.js","webpack:///./source/EventDispatcher.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","value","Event","undefined","_EventDispatcher","_EventDispatcher2","obj","default","_classCallCheck","instance","Constructor","TypeError","_typeof","Symbol","iterator","constructor","_createClass","defineProperties","target","props","length","descriptor","writable","key","protoProps","staticProps","hasOwnProp","type","data","defaultPrevented","ListenersRunner","listeners","onStopped","onComplete","_this","index","immediatelyStopped","stopImmediatePropagation","event","listener","augmentEvent","clearEvent","eventObject","stopPropagation","EventListeners","_this2","_listeners","_runners","removeRunner","runner","splice","indexOf","eventType","priorityOpt","priority","parseInt","getPrioritiesByKey","String","handler","handlers","createList","push","result","priorities","_this3","list","getOwnPropertyNames","handlerIndex","forEach","listenerRemoved","stopped","sort","a","b","createRunner","run","EventDispatcher","eventPreprocessor","noInit","arguments","initialize","_eventPreprocessor","add","has","remove","removeAll","getEvent","eventOrType","optionalData","isObject"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UA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H+IlChB,IAAK,0BACLtB,MAAO,SG7IemD,GACtB9E,KAAKwE,WAAWuC,UAAUjC,MHgJ1B7B,IAAK,gBACLtB,MAAO,SG9IKqC,EAAkBV,GAC9B,GAAIc,GAAckC,EAAgBU,SAAShD,EAAOV,EAC9CtD,MAAK2G,qBACPvC,EAAcpE,KAAK2G,mBAAmBpG,KAAKP,KAAMoE,IAEnDpE,KAAKwE,WAAWjE,KAAK6D,QHiJrBnB,IAAK,WACLtB,MAAO,SG/IOA,GACd,MAAyB,gBAAjB,KAAOA,EAAP,YAAAW,EAAOX,KAAkC,OAAVA,KHkJvCsB,IAAK,WACLtB,MAAO,SGhJOsF,EAAwBC,GACtC,GAAIlD,GAAQiD,CAIZ,OAHKX,GAAgBa,SAASF,KAC5BjD,EAAQ,GAAIsC,GAAgB1E,MAAMuD,OAAO8B,GAAcC,IAEjDlD,KHmJRf,IAAK,SACLtB,MAAO,SGjJK4E,GACZ,MAAO,IAAID,GAAgBC,OHwJtBD,IGjJTA,GAAgB1E,MAAQA,EHsJxBhC,EAAQqC,QGpJOqE","file":"event-dispatcher.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"EventDispatcher\"] = factory();\n\telse\n\t\troot[\"EventDispatcher\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"EventDispatcher\"] = factory();\n\telse\n\t\troot[\"EventDispatcher\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"http://localhost:8081/dist/\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Event = undefined;\n\nvar _EventDispatcher = __webpack_require__(1);\n\nvar _EventDispatcher2 = _interopRequireDefault(_EventDispatcher);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = _EventDispatcher2.default;\nexports.Event = _EventDispatcher.Event;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar hasOwnProp = function hasOwnProp(target, name) {\n return Object.prototype.hasOwnProperty.call(target, name);\n}; /**\n * Created by Oleg Galaburda on 09.02.16.\n * \n */\n\nvar Event = exports.Event = function () {\n function Event(type, data) {\n _classCallCheck(this, Event);\n\n this.type = type;\n this.data = data || null;\n this.defaultPrevented = false;\n }\n\n _createClass(Event, [{\n key: 'toJSON',\n value: function toJSON() {\n return { type: this.type, data: this.data };\n }\n }, {\n key: 'isDefaultPrevented',\n value: function isDefaultPrevented() {\n return this.defaultPrevented;\n }\n }, {\n key: 'preventDefault',\n value: function preventDefault() {\n this.defaultPrevented = true;\n }\n }]);\n\n return Event;\n}();\n\nvar ListenersRunner = function () {\n function ListenersRunner(listeners, onStopped, onComplete) {\n var _this = this;\n\n _classCallCheck(this, ListenersRunner);\n\n this.index = -1;\n this.immediatelyStopped = false;\n\n this.stopImmediatePropagation = function () {\n _this.immediatelyStopped = true;\n };\n\n this.listeners = listeners;\n this.onStopped = onStopped;\n this.onComplete = onComplete;\n }\n\n _createClass(ListenersRunner, [{\n key: 'run',\n value: function run(event, target) {\n var listener = void 0;\n var listeners = this.listeners;\n\n this.augmentEvent(event);\n // TODO this has to be handled in separate object ListenersRunner that should be\n // created for each call() call and asked for index validation on each listener remove.\n for (this.index = 0; this.index < listeners.length; this.index++) {\n if (this.immediatelyStopped) break;\n listener = listeners[this.index];\n listener.call(target, event);\n }\n this.clearEvent(event);\n this.onComplete(this);\n }\n }, {\n key: 'augmentEvent',\n value: function augmentEvent(eventObject) {\n var event = eventObject;\n event.stopPropagation = this.onStopped;\n event.stopImmediatePropagation = this.stopImmediatePropagation;\n }\n\n /* eslint class-methods-use-this: \"off\" */\n\n }, {\n key: 'clearEvent',\n value: function clearEvent(eventObject) {\n var event = eventObject;\n delete event.stopPropagation;\n delete event.stopImmediatePropagation;\n }\n }, {\n key: 'listenerRemoved',\n value: function listenerRemoved(listeners, index) {\n if (listeners === this.listeners && index <= this.index) {\n this.index--;\n }\n }\n }]);\n\n return ListenersRunner;\n}();\n\nvar EventListeners = function () {\n function EventListeners() {\n var _this2 = this;\n\n _classCallCheck(this, EventListeners);\n\n this._listeners = {};\n this._runners = [];\n\n this.removeRunner = function (runner) {\n _this2._runners.splice(_this2._runners.indexOf(runner), 1);\n };\n }\n /**\n * key - event Type\n * value - hash of priorities\n * key - priority\n * value - list of handlers\n * @type {Object>>}\n * @private\n */\n\n\n _createClass(EventListeners, [{\n key: 'createList',\n value: function createList(eventType, priorityOpt) {\n var priority = parseInt(priorityOpt, 10);\n var target = this.getPrioritiesByKey(eventType);\n var key = String(priority);\n var value = void 0;\n if (hasOwnProp(target, key)) {\n value = target[key];\n } else {\n value = [];\n target[key] = value;\n }\n return value;\n }\n }, {\n key: 'getPrioritiesByKey',\n value: function getPrioritiesByKey(key) {\n var value = void 0;\n if (hasOwnProp(this._listeners, key)) {\n value = this._listeners[key];\n } else {\n value = {};\n this._listeners[key] = value;\n }\n return value;\n }\n }, {\n key: 'add',\n value: function add(eventType, handler, priority) {\n var handlers = this.createList(eventType, priority);\n if (handlers.indexOf(handler) < 0) {\n handlers.push(handler);\n }\n }\n }, {\n key: 'has',\n value: function has(eventType) {\n var priority = void 0;\n var result = false;\n var priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n for (priority in priorities) {\n if (hasOwnProp(priorities, priority)) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n }, {\n key: 'remove',\n value: function remove(eventType, handler) {\n var _this3 = this;\n\n var priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n var list = Object.getOwnPropertyNames(priorities);\n var length = list.length;\n\n var _loop = function _loop(index) {\n var priority = list[index];\n var handlers = priorities[priority];\n var handlerIndex = handlers.indexOf(handler);\n if (handlerIndex >= 0) {\n handlers.splice(handlerIndex, 1);\n if (!handlers.length) {\n delete priorities[priority];\n }\n _this3._runners.forEach(function (runner) {\n runner.listenerRemoved(handlers, handlerIndex);\n });\n }\n };\n\n for (var index = 0; index < length; index++) {\n _loop(index);\n }\n }\n }\n }, {\n key: 'removeAll',\n value: function removeAll(eventType) {\n delete this._listeners[eventType];\n }\n }, {\n key: 'createRunner',\n value: function createRunner(handlers, onStopped) {\n var runner = new ListenersRunner(handlers, onStopped, this.removeRunner);\n this._runners.push(runner);\n return runner;\n }\n }, {\n key: 'call',\n value: function call(event, target) {\n var priorities = this.getPrioritiesByKey(event.type);\n var stopped = false;\n var stopPropagation = function stopPropagation() {\n stopped = true;\n };\n if (priorities) {\n // getOwnPropertyNames() or keys()?\n var list = Object.getOwnPropertyNames(priorities).sort(function (a, b) {\n return a - b;\n });\n var length = list.length;\n\n for (var index = 0; index < length; index++) {\n if (stopped) break;\n var _handlers = priorities[list[index]];\n // in case if all handlers of priority were removed while event\n // was dispatched and handlers become undefined.\n if (_handlers) {\n var _runner = this.createRunner(_handlers, stopPropagation);\n _runner.run(event, target);\n if (_runner.immediatelyStopped) break;\n }\n }\n }\n }\n }]);\n\n return EventListeners;\n}();\n\nvar EventDispatcher = function () {\n function EventDispatcher(eventPreprocessor) {\n var noInit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\n _classCallCheck(this, EventDispatcher);\n\n if (!noInit) {\n this.initialize(eventPreprocessor);\n }\n }\n\n /**\n * @private\n */\n\n\n _createClass(EventDispatcher, [{\n key: 'initialize',\n value: function initialize(eventPreprocessor) {\n this._eventPreprocessor = eventPreprocessor;\n this._listeners = new EventListeners();\n }\n }, {\n key: 'addEventListener',\n value: function addEventListener(eventType, listener) {\n var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n\n this._listeners.add(eventType, listener, -priority || 0);\n }\n }, {\n key: 'hasEventListener',\n value: function hasEventListener(eventType) {\n return this._listeners.has(eventType);\n }\n }, {\n key: 'removeEventListener',\n value: function removeEventListener(eventType, listener) {\n this._listeners.remove(eventType, listener);\n }\n }, {\n key: 'removeAllEventListeners',\n value: function removeAllEventListeners(eventType) {\n this._listeners.removeAll(eventType);\n }\n }, {\n key: 'dispatchEvent',\n value: function dispatchEvent(event, data) {\n var eventObject = EventDispatcher.getEvent(event, data);\n if (this._eventPreprocessor) {\n eventObject = this._eventPreprocessor.call(this, eventObject);\n }\n this._listeners.call(eventObject);\n }\n }], [{\n key: 'isObject',\n value: function isObject(value) {\n return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;\n }\n }, {\n key: 'getEvent',\n value: function getEvent(eventOrType, optionalData) {\n var event = eventOrType;\n if (!EventDispatcher.isObject(eventOrType)) {\n event = new EventDispatcher.Event(String(eventOrType), optionalData);\n }\n return event;\n }\n }, {\n key: 'create',\n value: function create(eventPreprocessor) {\n return new EventDispatcher(eventPreprocessor);\n }\n\n /* eslint no-undef: \"off\" */\n\n }]);\n\n return EventDispatcher;\n}();\n\nEventDispatcher.Event = Event;\n\nexports.default = EventDispatcher;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// event-dispatcher.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"http://localhost:8081/dist/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 756d1bc428259c6e1a11","import EventDispatcher, { Event } from './EventDispatcher';\n\nexport default EventDispatcher;\nexport { Event };\n\n\n\n// WEBPACK FOOTER //\n// ./source/index.js","/**\n * Created by Oleg Galaburda on 09.02.16.\n * @flow\n */\n\nimport type {\n EventObject,\n EventType,\n EventListener,\n EventProcessor,\n IEvent,\n IEventDispatcher,\n} from './TypeDefinition';\n\nconst hasOwnProp = (target: any, name: string): boolean => (\n Object.prototype.hasOwnProperty.call(target, name)\n);\n\nexport class Event implements IEvent {\n\n type: string;\n data: mixed;\n defaultPrevented: boolean;\n stopPropagation: ?() => void;\n stopImmediatePropagation: ?() => void;\n\n constructor(type: string, data: mixed) {\n this.type = type;\n this.data = data || null;\n this.defaultPrevented = false;\n }\n\n toJSON(): EventObject {\n return { type: this.type, data: this.data };\n }\n\n isDefaultPrevented(): boolean {\n return this.defaultPrevented;\n }\n\n preventDefault() {\n this.defaultPrevented = true;\n }\n}\n\ntype EventPrioritiesCollection = {\n [priority: string]: Array;\n}\n\ntype EventTypesCollection = {\n [eventType: string]: EventPrioritiesCollection;\n}\n\nclass ListenersRunner {\n index: number = -1;\n immediatelyStopped: boolean = false;\n listeners: EventListener[];\n onStopped: (runner: ListenersRunner) => void;\n onComplete: (runner: ListenersRunner) => void;\n\n constructor(\n listeners: EventListener[],\n onStopped: (runner: ListenersRunner) => void,\n onComplete: (runner: ListenersRunner) => void,\n ) {\n this.listeners = listeners;\n this.onStopped = onStopped;\n this.onComplete = onComplete;\n }\n\n stopImmediatePropagation = () => {\n this.immediatelyStopped = true;\n };\n\n run(event: EventObject, target: any) {\n let listener: EventListener;\n const { listeners } = this;\n this.augmentEvent(event);\n // TODO this has to be handled in separate object ListenersRunner that should be\n // created for each call() call and asked for index validation on each listener remove.\n for (this.index = 0; this.index < listeners.length; this.index++) {\n if (this.immediatelyStopped) break;\n listener = listeners[this.index];\n listener.call(target, event);\n }\n this.clearEvent(event);\n this.onComplete(this);\n }\n\n augmentEvent(eventObject: EventObject) {\n const event: EventObject = eventObject;\n event.stopPropagation = this.onStopped;\n event.stopImmediatePropagation = this.stopImmediatePropagation;\n }\n\n /* eslint class-methods-use-this: \"off\" */\n clearEvent(eventObject: EventObject) {\n const event: EventObject = eventObject;\n delete event.stopPropagation;\n delete event.stopImmediatePropagation;\n }\n\n listenerRemoved(listeners: EventListener[], index: number) {\n if (listeners === this.listeners && index <= this.index) {\n this.index--;\n }\n }\n}\n\nclass EventListeners {\n /**\n * key - event Type\n * value - hash of priorities\n * key - priority\n * value - list of handlers\n * @type {Object>>}\n * @private\n */\n _listeners: EventTypesCollection = {};\n _runners: ListenersRunner[] = [];\n\n createList(eventType: string, priorityOpt?: mixed): Array {\n const priority: number = parseInt(priorityOpt, 10);\n const target: EventPrioritiesCollection = this.getPrioritiesByKey(eventType);\n const key: string = String(priority);\n let value: Array;\n if (hasOwnProp(target, key)) {\n value = target[key];\n } else {\n value = [];\n target[key] = value;\n }\n return value;\n }\n\n getPrioritiesByKey(key: string): EventPrioritiesCollection {\n let value: EventPrioritiesCollection;\n if (hasOwnProp(this._listeners, key)) {\n value = this._listeners[key];\n } else {\n value = {};\n this._listeners[key] = value;\n }\n return value;\n }\n\n add(eventType: string, handler: EventListener, priority: number) {\n const handlers = this.createList(eventType, priority);\n if (handlers.indexOf(handler) < 0) {\n handlers.push(handler);\n }\n }\n\n has(eventType: string): boolean {\n let priority: string;\n let result = false;\n const priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n for (priority in priorities) {\n if (hasOwnProp(priorities, priority)) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n\n remove(eventType: string, handler) {\n const priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n const list = Object.getOwnPropertyNames(priorities);\n const { length } = list;\n for (let index = 0; index < length; index++) {\n const priority = list[index];\n const handlers = priorities[priority];\n const handlerIndex = handlers.indexOf(handler);\n if (handlerIndex >= 0) {\n handlers.splice(handlerIndex, 1);\n if (!handlers.length) {\n delete priorities[priority];\n }\n this._runners.forEach((runner) => {\n runner.listenerRemoved(handlers, handlerIndex);\n });\n }\n }\n }\n }\n\n removeAll(eventType: string) {\n delete this._listeners[eventType];\n }\n\n createRunner(handlers, onStopped) {\n const runner = new ListenersRunner(handlers, onStopped, this.removeRunner);\n this._runners.push(runner);\n return runner;\n }\n\n removeRunner = (runner) => {\n this._runners.splice(this._runners.indexOf(runner), 1);\n };\n\n call(event: EventObject, target: any) {\n const priorities = this.getPrioritiesByKey(event.type);\n let stopped = false;\n const stopPropagation = () => {\n stopped = true;\n };\n if (priorities) {\n // getOwnPropertyNames() or keys()?\n const list: string[] = Object\n .getOwnPropertyNames(priorities)\n .sort((a: any, b: any) => (a - b));\n const { length } = list;\n for (let index = 0; index < length; index++) {\n if (stopped) break;\n const handlers: Array = priorities[list[index]];\n // in case if all handlers of priority were removed while event\n // was dispatched and handlers become undefined.\n if (handlers) {\n const runner = this.createRunner(handlers, stopPropagation);\n runner.run(event, target);\n if (runner.immediatelyStopped) break;\n }\n }\n }\n }\n}\n\nclass EventDispatcher implements IEventDispatcher {\n\n _listeners: EventListeners;\n _eventPreprocessor: EventProcessor;\n\n constructor(eventPreprocessor: EventProcessor, noInit: boolean = false) {\n if (!noInit) {\n this.initialize(eventPreprocessor);\n }\n }\n\n /**\n * @private\n */\n initialize(eventPreprocessor: EventProcessor) {\n this._eventPreprocessor = eventPreprocessor;\n this._listeners = new EventListeners();\n }\n\n addEventListener(eventType: string, listener: EventListener, priority: number = 0) {\n this._listeners.add(eventType, listener, -priority || 0);\n }\n\n hasEventListener(eventType: string) {\n return this._listeners.has(eventType);\n }\n\n removeEventListener(eventType: string, listener: EventListener) {\n this._listeners.remove(eventType, listener);\n }\n\n removeAllEventListeners(eventType: string) {\n this._listeners.removeAll(eventType);\n }\n\n dispatchEvent(event: EventType, data: mixed) {\n let eventObject = EventDispatcher.getEvent(event, data);\n if (this._eventPreprocessor) {\n eventObject = this._eventPreprocessor.call(this, eventObject);\n }\n this._listeners.call(eventObject);\n }\n\n static isObject(value: mixed) {\n return (typeof value === 'object') && (value !== null);\n }\n\n static getEvent(eventOrType: EventType, optionalData: mixed): EventObject {\n let event = eventOrType;\n if (!EventDispatcher.isObject(eventOrType)) {\n event = new EventDispatcher.Event(String(eventOrType), optionalData);\n }\n return (event: any);\n }\n\n static create(eventPreprocessor: EventProcessor) {\n return new EventDispatcher(eventPreprocessor);\n }\n\n /* eslint no-undef: \"off\" */\n static Event: Class;\n}\n\nEventDispatcher.Event = Event;\n\nexport default EventDispatcher;\n\n\n\n// WEBPACK FOOTER //\n// ./source/EventDispatcher.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///event-dispatcher.min.js","webpack:///webpack/bootstrap c58930880204c27f8576","webpack:///./source/index.js","webpack:///./source/EventDispatcher.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","value","Event","undefined","_EventDispatcher","_EventDispatcher2","obj","default","_classCallCheck","instance","Constructor","TypeError","_typeof","Symbol","iterator","constructor","_createClass","defineProperties","target","props","length","descriptor","writable","key","protoProps","staticProps","hasOwnProp","type","data","arguments","defaultPrevented","ListenersRunner","listeners","onStopped","onComplete","_this","index","immediatelyStopped","stopImmediatePropagation","event","listener","augmentEvent","clearEvent","eventObject","stopPropagation","EventListeners","_this2","_listeners","_runners","removeRunner","runner","splice","indexOf","eventType","priorityOpt","priority","parseInt","getPrioritiesByKey","String","handler","handlers","createList","push","result","priorities","_this3","list","getOwnPropertyNames","handlerIndex","forEach","listenerRemoved","stopped","sort","a","b","createRunner","run","EventDispatcher","eventPreprocessor","noInit","initialize","_eventPreprocessor","add","has","remove","removeAll","getEvent","eventOrType","optionalData","isObject"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,gBAAAD,IAEAD,EAAA,gBAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,EAAAF,EACAG,GAAA,EACAV,WAUA,OANAK,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,GAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KA4DA,OAhCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,SAAAd,EAAAe,EAAAC,GACAV,EAAAW,EAAAjB,EAAAe,IACAG,OAAAC,eAAAnB,EAAAe,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAV,EAAAiB,EAAA,SAAAtB,GACA,GAAAe,GAAAf,KAAAuB,WACA,WAA2B,MAAAvB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAK,GAAAQ,EAAAE,EAAA,IAAAA,GACAA,GAIAV,EAAAW,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAjB,KAAAc,EAAAC,IAGtDpB,EAAAuB,EAAA,8BAGAvB,IAAAwB,EAAA,KDgBM,SAAU7B,EAAQD,EAASM,GAEjC,YAGAY,QAAOC,eAAenB,EAAS,cAC7B+B,OAAO,IAET/B,EAAQgC,UAAQC,EErFhB,IAAAC,GAAA5B,EAAA,GFyFI6B,EAEJ,SAAgCC,GAAO,MAAOA,IAAOA,EAAIZ,WA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BH,EAC1BxG,KAAKyE,WAAa,GAAIF,MH+ItBtB,IAAK,mBACLtB,MAAO,SG7IQoD,EAAmBb,GAA+C,GAAtBe,GAAsB1B,UAAAT,OAAA,OAAAjB,KAAA0B,UAAA,GAAAA,UAAA,GAAH,CAC9EvD,MAAKyE,WAAWmC,IAAI7B,EAAWb,GAAWe,GAAY,MHkJtDhC,IAAK,mBACLtB,MAAO,SGhJQoD,GACf,MAAO/E,MAAKyE,WAAWoC,IAAI9B,MHmJ3B9B,IAAK,sBACLtB,MAAO,SGjJWoD,EAAmBb,GACrClE,KAAKyE,WAAWqC,OAAO/B,EAAWb,MHoJlCjB,IAAK,0BACLtB,MAAO,SGlJeoD,GACtB/E,KAAKyE,WAAWsC,UAAUhC,MHqJ1B9B,IAAK,gBACLtB,MAAO,SGnJKsC,EAAkBX,GAC9B,GAAIe,GAAckC,EAAgBS,SAAS/C,EAAOX,EAC9CtD,MAAK2G,qBACPtC,EAAcrE,KAAK2G,mBAAmBpG,KAAKP,KAAMqE,IAEnDrE,KAAKyE,WAAWlE,KAAK8D,QHsJrBpB,IAAK,WACLtB,MAAO,SGpJOA,GACd,MAAyB,gBAAjB,KAAOA,EAAP,YAAAW,EAAOX,KAAkC,OAAVA,KHuJvCsB,IAAK,WACLtB,MAAO,SGrJOsF,EAAwBC,GACtC,GAAIjD,GAAQgD,CAIZ,OAHKV,GAAgBY,SAASF,KAC5BhD,EAAQ,GAAIsC,GAAgB3E,MAAMwD,OAAO6B,GAAcC,IAEjDjD,KHwJRhB,IAAK,SACLtB,MAAO,SGtJK6E,GACZ,MAAO,IAAID,GAAgBC,OH6JtBD,IGtJTA,GAAgB3E,MAAQA,EH2JxBhC,EAAQqC,QGzJOsE","file":"event-dispatcher.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"EventDispatcher\"] = factory();\n\telse\n\t\troot[\"EventDispatcher\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"EventDispatcher\"] = factory();\n\telse\n\t\troot[\"EventDispatcher\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"http://localhost:8081/dist/\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Event = undefined;\n\nvar _EventDispatcher = __webpack_require__(1);\n\nvar _EventDispatcher2 = _interopRequireDefault(_EventDispatcher);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = _EventDispatcher2.default;\nexports.Event = _EventDispatcher.Event;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar hasOwnProp = function hasOwnProp(target, name) {\n return Object.prototype.hasOwnProperty.call(target, name);\n}; /**\r\n * Created by Oleg Galaburda on 09.02.16.\r\n * \r\n */\n\nvar Event = exports.Event = function () {\n function Event(type) {\n var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n\n _classCallCheck(this, Event);\n\n this.type = type;\n this.data = data;\n this.defaultPrevented = false;\n }\n\n _createClass(Event, [{\n key: 'toJSON',\n value: function toJSON() {\n return { type: this.type, data: this.data };\n }\n }, {\n key: 'isDefaultPrevented',\n value: function isDefaultPrevented() {\n return this.defaultPrevented;\n }\n }, {\n key: 'preventDefault',\n value: function preventDefault() {\n this.defaultPrevented = true;\n }\n }]);\n\n return Event;\n}();\n\nvar ListenersRunner = function () {\n function ListenersRunner(listeners, onStopped, onComplete) {\n var _this = this;\n\n _classCallCheck(this, ListenersRunner);\n\n this.index = -1;\n this.immediatelyStopped = false;\n\n this.stopImmediatePropagation = function () {\n _this.immediatelyStopped = true;\n };\n\n this.listeners = listeners;\n this.onStopped = onStopped;\n this.onComplete = onComplete;\n }\n\n _createClass(ListenersRunner, [{\n key: 'run',\n value: function run(event, target) {\n var listener = void 0;\n var listeners = this.listeners;\n\n this.augmentEvent(event);\n // TODO this has to be handled in separate object ListenersRunner that should be\n // created for each call() call and asked for index validation on each listener remove.\n for (this.index = 0; this.index < listeners.length; this.index++) {\n if (this.immediatelyStopped) break;\n listener = listeners[this.index];\n listener.call(target, event);\n }\n this.clearEvent(event);\n this.onComplete(this);\n }\n }, {\n key: 'augmentEvent',\n value: function augmentEvent(eventObject) {\n var event = eventObject;\n event.stopPropagation = this.onStopped;\n event.stopImmediatePropagation = this.stopImmediatePropagation;\n }\n\n /* eslint class-methods-use-this: \"off\" */\n\n }, {\n key: 'clearEvent',\n value: function clearEvent(eventObject) {\n var event = eventObject;\n delete event.stopPropagation;\n delete event.stopImmediatePropagation;\n }\n }, {\n key: 'listenerRemoved',\n value: function listenerRemoved(listeners, index) {\n if (listeners === this.listeners && index <= this.index) {\n this.index--;\n }\n }\n }]);\n\n return ListenersRunner;\n}();\n\nvar EventListeners = function () {\n function EventListeners() {\n var _this2 = this;\n\n _classCallCheck(this, EventListeners);\n\n this._listeners = {};\n this._runners = [];\n\n this.removeRunner = function (runner) {\n _this2._runners.splice(_this2._runners.indexOf(runner), 1);\n };\n }\n /**\r\n * key - event Type\r\n * value - hash of priorities\r\n * key - priority\r\n * value - list of handlers\r\n * @type {Object>>}\r\n * @private\r\n */\n\n\n _createClass(EventListeners, [{\n key: 'createList',\n value: function createList(eventType, priorityOpt) {\n var priority = parseInt(priorityOpt, 10);\n var target = this.getPrioritiesByKey(eventType);\n var key = String(priority);\n var value = void 0;\n if (hasOwnProp(target, key)) {\n value = target[key];\n } else {\n value = [];\n target[key] = value;\n }\n return value;\n }\n }, {\n key: 'getPrioritiesByKey',\n value: function getPrioritiesByKey(key) {\n var value = void 0;\n if (hasOwnProp(this._listeners, key)) {\n value = this._listeners[key];\n } else {\n value = {};\n this._listeners[key] = value;\n }\n return value;\n }\n }, {\n key: 'add',\n value: function add(eventType, handler, priority) {\n var handlers = this.createList(eventType, priority);\n if (handlers.indexOf(handler) < 0) {\n handlers.push(handler);\n }\n }\n }, {\n key: 'has',\n value: function has(eventType) {\n var priority = void 0;\n var result = false;\n var priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n for (priority in priorities) {\n if (hasOwnProp(priorities, priority)) {\n result = true;\n break;\n }\n }\n }\n return result;\n }\n }, {\n key: 'remove',\n value: function remove(eventType, handler) {\n var _this3 = this;\n\n var priorities = this.getPrioritiesByKey(eventType);\n if (priorities) {\n var list = Object.getOwnPropertyNames(priorities);\n var length = list.length;\n\n var _loop = function _loop(index) {\n var priority = list[index];\n var handlers = priorities[priority];\n var handlerIndex = handlers.indexOf(handler);\n if (handlerIndex >= 0) {\n handlers.splice(handlerIndex, 1);\n if (!handlers.length) {\n delete priorities[priority];\n }\n _this3._runners.forEach(function (runner) {\n runner.listenerRemoved(handlers, handlerIndex);\n });\n }\n };\n\n for (var index = 0; index < length; index++) {\n _loop(index);\n }\n }\n }\n }, {\n key: 'removeAll',\n value: function removeAll(eventType) {\n delete this._listeners[eventType];\n }\n }, {\n key: 'createRunner',\n value: function createRunner(handlers, onStopped) {\n var runner = new ListenersRunner(handlers, onStopped, this.removeRunner);\n this._runners.push(runner);\n return runner;\n }\n }, {\n key: 'call',\n value: function call(event, target) {\n var priorities = this.getPrioritiesByKey(event.type);\n var stopped = false;\n var stopPropagation = function stopPropagation() {\n stopped = true;\n };\n if (priorities) {\n // getOwnPropertyNames() or keys()?\n var list = Object.getOwnPropertyNames(priorities).sort(function (a, b) {\n return a - b;\n });\n var length = list.length;\n\n for (var index = 0; index < length; index++) {\n if (stopped) break;\n var _handlers = priorities[list[index]];\n // in case if all handlers of priority were removed while event\n // was dispatched and handlers become undefined.\n if (_handlers) {\n var _runner = this.createRunner(_handlers, stopPropagation);\n _runner.run(event, target);\n if (_runner.immediatelyStopped) break;\n }\n }\n }\n }\n }]);\n\n return EventListeners;\n}();\n\nvar EventDispatcher = function () {\n function EventDispatcher() {\n var eventPreprocessor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n var noInit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\n _classCallCheck(this, EventDispatcher);\n\n if (!noInit) {\n this.initialize(eventPreprocessor);\n }\n }\n\n /**\r\n * @private\r\n */\n\n\n _createClass(EventDispatcher, [{\n key: 'initialize',\n value: function initialize() {\n var eventPreprocessor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\n this._eventPreprocessor = eventPreprocessor;\n this._listeners = new EventListeners();\n }\n }, {\n key: 'addEventListener',\n value: function addEventListener(eventType, listener) {\n var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n\n this._listeners.add(eventType, listener, -priority || 0);\n }\n }, {\n key: 'hasEventListener',\n value: function hasEventListener(eventType) {\n return this._listeners.has(eventType);\n }\n }, {\n key: 'removeEventListener',\n value: function removeEventListener(eventType, listener) {\n this._listeners.remove(eventType, listener);\n }\n }, {\n key: 'removeAllEventListeners',\n value: function removeAllEventListeners(eventType) {\n this._listeners.removeAll(eventType);\n }\n }, {\n key: 'dispatchEvent',\n value: function dispatchEvent(event, data) {\n var eventObject = EventDispatcher.getEvent(event, data);\n if (this._eventPreprocessor) {\n eventObject = this._eventPreprocessor.call(this, eventObject);\n }\n this._listeners.call(eventObject);\n }\n }], [{\n key: 'isObject',\n value: function isObject(value) {\n return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;\n }\n }, {\n key: 'getEvent',\n value: function getEvent(eventOrType, optionalData) {\n var event = eventOrType;\n if (!EventDispatcher.isObject(eventOrType)) {\n event = new EventDispatcher.Event(String(eventOrType), optionalData);\n }\n return event;\n }\n }, {\n key: 'create',\n value: function create(eventPreprocessor) {\n return new EventDispatcher(eventPreprocessor);\n }\n\n /* eslint no-undef: \"off\" */\n\n }]);\n\n return EventDispatcher;\n}();\n\nEventDispatcher.Event = Event;\n\nexports.default = EventDispatcher;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// event-dispatcher.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"http://localhost:8081/dist/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap c58930880204c27f8576","import EventDispatcher, { Event } from './EventDispatcher';\n\nexport default EventDispatcher;\nexport { Event };\n\n\n\n// WEBPACK FOOTER //\n// ./source/index.js","/**\r\n * Created by Oleg Galaburda on 09.02.16.\r\n * @flow\r\n */\r\n\r\nimport type {\r\n EventObject,\r\n EventType,\r\n EventListener,\r\n EventProcessor,\r\n IEvent,\r\n IEventDispatcher,\r\n} from './TypeDefinition';\r\n\r\nconst hasOwnProp = (target: any, name: string): boolean => (\r\n Object.prototype.hasOwnProperty.call(target, name)\r\n);\r\n\r\nexport class Event implements IEvent {\r\n\r\n type: string;\r\n data: mixed;\r\n defaultPrevented: boolean;\r\n stopPropagation: ?() => void;\r\n stopImmediatePropagation: ?() => void;\r\n\r\n constructor(type: string, data: mixed = null) {\r\n this.type = type;\r\n this.data = data;\r\n this.defaultPrevented = false;\r\n }\r\n\r\n toJSON(): EventObject {\r\n return { type: this.type, data: this.data };\r\n }\r\n\r\n isDefaultPrevented(): boolean {\r\n return this.defaultPrevented;\r\n }\r\n\r\n preventDefault() {\r\n this.defaultPrevented = true;\r\n }\r\n}\r\n\r\ntype EventPrioritiesCollection = {\r\n [priority: string]: Array;\r\n}\r\n\r\ntype EventTypesCollection = {\r\n [eventType: string]: EventPrioritiesCollection;\r\n}\r\n\r\nclass ListenersRunner {\r\n index: number = -1;\r\n immediatelyStopped: boolean = false;\r\n listeners: EventListener[];\r\n onStopped: (runner: ListenersRunner) => void;\r\n onComplete: (runner: ListenersRunner) => void;\r\n\r\n constructor(\r\n listeners: EventListener[],\r\n onStopped: (runner: ListenersRunner) => void,\r\n onComplete: (runner: ListenersRunner) => void,\r\n ) {\r\n this.listeners = listeners;\r\n this.onStopped = onStopped;\r\n this.onComplete = onComplete;\r\n }\r\n\r\n stopImmediatePropagation = () => {\r\n this.immediatelyStopped = true;\r\n };\r\n\r\n run(event: EventObject, target: any) {\r\n let listener: EventListener;\r\n const { listeners } = this;\r\n this.augmentEvent(event);\r\n // TODO this has to be handled in separate object ListenersRunner that should be\r\n // created for each call() call and asked for index validation on each listener remove.\r\n for (this.index = 0; this.index < listeners.length; this.index++) {\r\n if (this.immediatelyStopped) break;\r\n listener = listeners[this.index];\r\n listener.call(target, event);\r\n }\r\n this.clearEvent(event);\r\n this.onComplete(this);\r\n }\r\n\r\n augmentEvent(eventObject: EventObject) {\r\n const event: EventObject = eventObject;\r\n event.stopPropagation = this.onStopped;\r\n event.stopImmediatePropagation = this.stopImmediatePropagation;\r\n }\r\n\r\n /* eslint class-methods-use-this: \"off\" */\r\n clearEvent(eventObject: EventObject) {\r\n const event: EventObject = eventObject;\r\n delete event.stopPropagation;\r\n delete event.stopImmediatePropagation;\r\n }\r\n\r\n listenerRemoved(listeners: EventListener[], index: number) {\r\n if (listeners === this.listeners && index <= this.index) {\r\n this.index--;\r\n }\r\n }\r\n}\r\n\r\nclass EventListeners {\r\n /**\r\n * key - event Type\r\n * value - hash of priorities\r\n * key - priority\r\n * value - list of handlers\r\n * @type {Object>>}\r\n * @private\r\n */\r\n _listeners: EventTypesCollection = {};\r\n _runners: ListenersRunner[] = [];\r\n\r\n createList(eventType: string, priorityOpt?: mixed): Array {\r\n const priority: number = parseInt(priorityOpt, 10);\r\n const target: EventPrioritiesCollection = this.getPrioritiesByKey(eventType);\r\n const key: string = String(priority);\r\n let value: Array;\r\n if (hasOwnProp(target, key)) {\r\n value = target[key];\r\n } else {\r\n value = [];\r\n target[key] = value;\r\n }\r\n return value;\r\n }\r\n\r\n getPrioritiesByKey(key: string): EventPrioritiesCollection {\r\n let value: EventPrioritiesCollection;\r\n if (hasOwnProp(this._listeners, key)) {\r\n value = this._listeners[key];\r\n } else {\r\n value = {};\r\n this._listeners[key] = value;\r\n }\r\n return value;\r\n }\r\n\r\n add(eventType: string, handler: EventListener, priority: number) {\r\n const handlers = this.createList(eventType, priority);\r\n if (handlers.indexOf(handler) < 0) {\r\n handlers.push(handler);\r\n }\r\n }\r\n\r\n has(eventType: string): boolean {\r\n let priority: string;\r\n let result = false;\r\n const priorities = this.getPrioritiesByKey(eventType);\r\n if (priorities) {\r\n for (priority in priorities) {\r\n if (hasOwnProp(priorities, priority)) {\r\n result = true;\r\n break;\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n remove(eventType: string, handler) {\r\n const priorities = this.getPrioritiesByKey(eventType);\r\n if (priorities) {\r\n const list = Object.getOwnPropertyNames(priorities);\r\n const { length } = list;\r\n for (let index = 0; index < length; index++) {\r\n const priority = list[index];\r\n const handlers = priorities[priority];\r\n const handlerIndex = handlers.indexOf(handler);\r\n if (handlerIndex >= 0) {\r\n handlers.splice(handlerIndex, 1);\r\n if (!handlers.length) {\r\n delete priorities[priority];\r\n }\r\n this._runners.forEach((runner) => {\r\n runner.listenerRemoved(handlers, handlerIndex);\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n removeAll(eventType: string) {\r\n delete this._listeners[eventType];\r\n }\r\n\r\n createRunner(handlers, onStopped) {\r\n const runner = new ListenersRunner(handlers, onStopped, this.removeRunner);\r\n this._runners.push(runner);\r\n return runner;\r\n }\r\n\r\n removeRunner = (runner) => {\r\n this._runners.splice(this._runners.indexOf(runner), 1);\r\n };\r\n\r\n call(event: EventObject, target: any) {\r\n const priorities = this.getPrioritiesByKey(event.type);\r\n let stopped = false;\r\n const stopPropagation = () => {\r\n stopped = true;\r\n };\r\n if (priorities) {\r\n // getOwnPropertyNames() or keys()?\r\n const list: string[] = Object\r\n .getOwnPropertyNames(priorities)\r\n .sort((a: any, b: any) => (a - b));\r\n const { length } = list;\r\n for (let index = 0; index < length; index++) {\r\n if (stopped) break;\r\n const handlers: Array = priorities[list[index]];\r\n // in case if all handlers of priority were removed while event\r\n // was dispatched and handlers become undefined.\r\n if (handlers) {\r\n const runner = this.createRunner(handlers, stopPropagation);\r\n runner.run(event, target);\r\n if (runner.immediatelyStopped) break;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nclass EventDispatcher implements IEventDispatcher {\r\n\r\n _listeners: EventListeners;\r\n _eventPreprocessor: EventProcessor;\r\n\r\n constructor(eventPreprocessor: EventProcessor = null, noInit: boolean = false) {\r\n if (!noInit) {\r\n this.initialize(eventPreprocessor);\r\n }\r\n }\r\n\r\n /**\r\n * @private\r\n */\r\n initialize(eventPreprocessor: EventProcessor = null) {\r\n this._eventPreprocessor = eventPreprocessor;\r\n this._listeners = new EventListeners();\r\n }\r\n\r\n addEventListener(eventType: string, listener: EventListener, priority: number = 0) {\r\n this._listeners.add(eventType, listener, -priority || 0);\r\n }\r\n\r\n hasEventListener(eventType: string) {\r\n return this._listeners.has(eventType);\r\n }\r\n\r\n removeEventListener(eventType: string, listener: EventListener) {\r\n this._listeners.remove(eventType, listener);\r\n }\r\n\r\n removeAllEventListeners(eventType: string) {\r\n this._listeners.removeAll(eventType);\r\n }\r\n\r\n dispatchEvent(event: EventType, data: mixed) {\r\n let eventObject = EventDispatcher.getEvent(event, data);\r\n if (this._eventPreprocessor) {\r\n eventObject = this._eventPreprocessor.call(this, eventObject);\r\n }\r\n this._listeners.call(eventObject);\r\n }\r\n\r\n static isObject(value: mixed) {\r\n return (typeof value === 'object') && (value !== null);\r\n }\r\n\r\n static getEvent(eventOrType: EventType, optionalData: mixed): EventObject {\r\n let event = eventOrType;\r\n if (!EventDispatcher.isObject(eventOrType)) {\r\n event = new EventDispatcher.Event(String(eventOrType), optionalData);\r\n }\r\n return (event: any);\r\n }\r\n\r\n static create(eventPreprocessor: EventProcessor) {\r\n return new EventDispatcher(eventPreprocessor);\r\n }\r\n\r\n /* eslint no-undef: \"off\" */\r\n static Event: Class;\r\n}\r\n\r\nEventDispatcher.Event = Event;\r\n\r\nexport default EventDispatcher;\r\n\n\n\n// WEBPACK FOOTER //\n// ./source/EventDispatcher.js"],"sourceRoot":""} \ No newline at end of file