compago-listener
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -55,3 +55,3 @@ 'use strict'; | ||
event.push([this, callback]); | ||
if (! ~listensTo.indexOf(eventName)) listensTo.push(eventName); | ||
if (!~listensTo.indexOf(eventName)) listensTo.push(eventName); | ||
} | ||
@@ -135,3 +135,4 @@ return this; | ||
* Model.emit('change', {previous: 'Zaphod'}); | ||
* // `View.render` is invoked with a parameter `{event: 'change', emitter: Model, previous: 'Zaphod'}` | ||
* // `View.render` is invoked with a parameter | ||
* `{event: 'change', emitter: Model, previous: 'Zaphod'}` | ||
* | ||
@@ -142,6 +143,3 @@ * Collection.emit('change', {}, Model); | ||
*/ | ||
emit(name) { | ||
let data = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
let emitter = arguments.length <= 2 || arguments[2] === undefined ? this : arguments[2]; | ||
emit(name, data = {}, emitter = this) { | ||
if (!name) return this; | ||
@@ -180,5 +178,5 @@ if (!this._events || !this._events.size) return this; | ||
events.forEach(event => { | ||
for (const listener of event) { | ||
event.forEach(listener => { | ||
listener[0]._listeners.delete(this); | ||
} | ||
}); | ||
}); | ||
@@ -189,1 +187,3 @@ this._events = undefined; | ||
}; | ||
exports.default = Listener; |
{ | ||
"name": "compago-listener", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A mixin that provides methods to handle events.", | ||
@@ -40,27 +40,51 @@ "main": "dist/node/index.js", | ||
}, | ||
"eslintConfig": { | ||
"extends": "airbnb-base", | ||
"rules": { | ||
"no-underscore-dangle": 0, | ||
"no-nested-ternary": 1, | ||
"no-plusplus": 0, | ||
"no-bitwise": 1, | ||
"class-methods-use-this": 1, | ||
"no-continue": 1, | ||
"eqeqeq": [ | ||
2, | ||
"smart" | ||
], | ||
"no-param-reassign": [ | ||
2, | ||
{ | ||
"props": false | ||
} | ||
], | ||
"valid-jsdoc": [ | ||
2, | ||
{ | ||
"prefer": { | ||
"return": "returns" | ||
}, | ||
"requireReturnDescription": false, | ||
"requireParamDescription": false | ||
} | ||
] | ||
} | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"node5" | ||
"node6" | ||
] | ||
}, | ||
"eslintConfig": { | ||
"extends": "airbnb", | ||
"rules": { | ||
"no-nested-ternary": 1 | ||
} | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.3.17", | ||
"babel-preset-es2015": "^6.3.13", | ||
"babel-preset-node5": "^10.1.1", | ||
"babel-cli": "^6.16.0", | ||
"babel-preset-node6": "^11.0.0", | ||
"codecov.io": "^0.1.6", | ||
"eslint": "^1.10.3", | ||
"eslint-config-airbnb": "^2.1.1", | ||
"eslint-plugin-react": "^3.13.1", | ||
"expect": "^1.13.4", | ||
"istanbul": "^1.0.0-alpha.2", | ||
"eslint": "^3.7.1", | ||
"eslint-config-airbnb-base": "^8.0.0", | ||
"eslint-plugin-import": "^2.0.1", | ||
"expect": "^1.20.2", | ||
"istanbul": "^1.1.0-alpha.1", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^2.3.4", | ||
"rimraf": "^2.5.0" | ||
"mocha": "^3.1.2", | ||
"rimraf": "^2.5.4" | ||
} | ||
} |
@@ -80,3 +80,4 @@ /** Used to split event names */ | ||
if (!allListeners || !allListeners.size) return this; | ||
const nameList = name ? _reEventSplitter.test(name) ? name.split(_reEventSplitter) : [name] : undefined; | ||
const nameList = name ? _reEventSplitter.test(name) ? | ||
name.split(_reEventSplitter) : [name] : undefined; | ||
const deleteListener = !name && !callback; | ||
@@ -130,3 +131,4 @@ let listeners = allListeners; | ||
* Model.emit('change', {previous: 'Zaphod'}); | ||
* // `View.render` is invoked with a parameter `{event: 'change', emitter: Model, previous: 'Zaphod'}` | ||
* // `View.render` is invoked with a parameter | ||
* `{event: 'change', emitter: Model, previous: 'Zaphod'}` | ||
* | ||
@@ -171,5 +173,5 @@ * Collection.emit('change', {}, Model); | ||
events.forEach((event) => { | ||
for (const listener of event) { | ||
event.forEach((listener) => { | ||
listener[0]._listeners.delete(this); | ||
} | ||
}); | ||
}); | ||
@@ -180,1 +182,3 @@ this._events = undefined; | ||
}; | ||
export default Listener; |
@@ -1,6 +0,5 @@ | ||
/* eslint-env node, mocha */ | ||
const Listener = require('../src/index').Listener; | ||
const expect = require('expect'); | ||
import expect from 'expect'; | ||
import Listener from '../src/index'; | ||
@@ -7,0 +6,0 @@ describe('Listener', () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
11
10
478
21486