SubscriptionToken should implement IDisposable

Topics: Prism v4 - WPF 4
Sep 8, 2010 at 6:15 PM

This would make it substantially easier to unsubscribe. I just need to dispose the subscription.

All in all, I'd align the entire event aggregator with IObservable/IObserver, to make it future-proof to the Reactive Extensions. Implementing IDisposable is just one tiny bit of it.

Sep 8, 2010 at 11:48 PM



Thanks for your feedback. I will copy this as a work-item and this way the prism team will be notified about this. Additionally, the community could vote the feature.  

When you use Event Aggregator in Prism, the possibility of unsubscribing is meant to no longer handle an event from a particular component. It can be achieved by using the subscription token or the handler instead. For more information you could take a look at the following documentation section on MSDN:

That said, your approach seems to be possible, but I’m not sure if implementing IDisposable will make this scenario achievable, since the subscriber has to indicate the EventAggregator instance from where it has to be unsubscribed.

Therefore, if the idea is to call a particular method for unsubscribing, you could create an extensions method which receives the event aggregator instance as parameter.

Regarding to Reactive Extensions, I’m not aware whether implementing IDisposable could help.

Please let me know if this helps.

Fernando Antivero

Sep 8, 2010 at 11:49 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.