Skip to content
This repository has been archived by the owner on Dec 11, 2018. It is now read-only.

Commit

Permalink
Make listenOnce return its unlisten function.
Browse files Browse the repository at this point in the history
  • Loading branch information
pluma committed Dec 17, 2014
1 parent aab6238 commit 8d54d99
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ axn.methods = {
};
},
listenOnce: function (fn, ctx) {
var unlisten = this.listen(callThenUnlisten, ctx);
function callThenUnlisten(data) {
fn(data);
unlisten();
}
var unlisten = this.listen(callThenUnlisten, ctx);
return unlisten;
},
unlisten: function (fn, ctx) {
for (var i = 0; i < this._listeners.length; i++) {
Expand Down

0 comments on commit 8d54d99

Please sign in to comment.