Skip to content
This repository was archived by the owner on Dec 15, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/util/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@
return this;
}

var listeners = this._topics[ topic ]
,l = listeners && listeners.length
var l = this._topics[ topic ] && this._topics[ topic ].length
,listeners
,handler
,e
,scratch = Physics.scratchpad()
Expand All @@ -183,11 +183,12 @@
// reverse iterate so priorities work out correctly
while ( l-- ){

handler = listeners[ l ];
handler( data, e );
listeners = this._topics[ topic ];
handler = listeners && listeners[ l ];
handler && handler( data, e );

// if _one_ flag is set, the unsubscribe
if ( handler._one_ ){
if ( handler && handler._one_ ){
listeners.splice( l, 1 );
}
}
Expand Down