Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/immediate exceptions not working with namespaces #75

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ https://github.com/mroderick/PubSubJS
while( position !== -1 ){
topic = topic.substr( 0, position );
position = topic.lastIndexOf('.');
deliverMessage( message, topic, data );
deliverMessage( message, topic, data, immediateExceptions );
}
};
}
Expand Down
21 changes: 21 additions & 0 deletions test/test-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,27 @@
delete PubSub.immediateExceptions;
},

"publish method should fail immediately on exceptions in namespaces when immediateExceptions is true" : function(){
var func1 = function(){
throw('some error');
},
spy1 = this.spy();

PubSub.subscribe( 'buy', func1 );
PubSub.subscribe( 'buy', spy1 );

PubSub.immediateExceptions = true;

assert.exception( function(){
PubSub.publishSync( 'buy.tomatoes', 'some data' );
});

refute( spy1.called );

// make sure we restore PubSub to it's original state
delete PubSub.immediateExceptions;
},

"publish should call all subscribers, even when there are unsubscriptions within" : function(done){
var topic = TestHelper.getUniqueString(),
spy1 = this.spy(),
Expand Down