badrinarayanan / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

goog.pubsub throws Errors if you dispose during publish #584

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add a subscriber that disposes a pubsub on an event
2. Publish the event

What is the expected output? 
I expect the PubSub to finish handling subscribers, like goog.events does in 
the same scenario.

What do you see instead?
PubSub throws an exception

I'm contributing a fix on behalf of Jacob Thornton, which I've posted here:
http://codereview.appspot.com/12874043

Original issue reported on code.google.com by Nicholas.J.Santos on 13 Aug 2013 at 5:54

GoogleCodeExporter commented 8 years ago
Is there any reason for PubSub to be disposable these days?

Original comment by johnl...@google.com on 13 Aug 2013 at 9:23

GoogleCodeExporter commented 8 years ago
a few reasons:
1) You want to make sure that no one is using the dead object
2) You will generally need some unsubscribeAll() mechanism for any object with 
a limited life-cycle

Original comment by Nicholas.J.Santos on 13 Aug 2013 at 9:34

GoogleCodeExporter commented 8 years ago
Not sure if this should be added as a separate issue, but the same issue apply 
for subscribeOnce().

Original comment by laurit...@komogvind.dk on 4 Sep 2014 at 10:05