A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/mroderick/PubSubJS/issues/26 below:

Unsubscribe inside publish triggers an error · Issue #26 · mroderick/PubSubJS · GitHub

Hi

Firstly thanks for this great piece of asynchronous code!

Sometimes there is a need to unsubscribe from a message in a callback. At the moment (in some conditions) it triggers an error. Code example:

var mySubscriber = function(msg, data) {
  PubSub.unsubscribe(mySubscriber);
  console.log('mySubscriber');
};
var mySubscriber2 = function(msg, data) {
  console.log('mySubscriber2');
};

PubSub.subscribe( 'MY MESSAGE', mySubscriber);
PubSub.subscribe( 'MY MESSAGE', mySubscriber2);

PubSub.publish( 'MY MESSAGE', 'hello world!' );

BR


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4