collectionize
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -91,2 +91,13 @@ (function () { | ||
self.uniqueOn = function (eventNames, fn) { | ||
var namespace = _.uniqueId(); | ||
var namespacedEventNames = eventNames.split(' ').map(function (eventName) { | ||
return eventName + '.' + namespace; | ||
}).join(' '); | ||
self.on(namespacedEventNames, fn); | ||
return namespace; | ||
}; | ||
self.trigger = function () { | ||
@@ -96,3 +107,3 @@ var args = _.toArray(arguments); | ||
nativeEach(self.listeners, function (listener) { | ||
if (listener.name === eventName) { | ||
if (listener.name === eventName || listener.name.indexOf(eventName + '.') === 0) { | ||
listener.fn.apply(this, args); | ||
@@ -105,3 +116,3 @@ } | ||
_.remove(self.listeners, function (listener) { | ||
return listener.name === eventName; | ||
return listener.name === eventName || listener.name.indexOf(eventName + '.') === 0; | ||
}); | ||
@@ -108,0 +119,0 @@ }; |
{ | ||
"name": "collectionize", | ||
"description": "A lightweight JS model/collection library.", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"repository": "https://github.com/andrewchilds/collectionize.git", | ||
@@ -6,0 +6,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
45988
229