Release all event subscriptions

Posted by Lieven De Foor on 10-Jul-2017 03:14

Hi,

Is there a way to release all event subscriptions for a particular event, without adding extra subscription tracking code?

In C# you can set the delegate to null, but the ABL implementation of events hides (or doesn't have) this...

Posted by Mike Fechner on 10-Jul-2017 03:18

I doubt that’s available. But I’d give you my vote.

All Replies

Posted by Mike Fechner on 10-Jul-2017 03:18

I doubt that’s available. But I’d give you my vote.

Posted by Patrick Tingen on 11-Jul-2017 03:44

As far as I know, this is not possible. What I would like is to have some reflection functions on pub/sub together with the ability to dynamically add and delete subscriptions.

Your only option currently is to check on some global condition at the start of your event handler.

Posted by Lieven De Foor on 11-Jul-2017 10:11

Adding code at the handler side isn't ideal (you can't force that).

The only workaround I see is not use events or make them private, and use an observer pattern.

Since you somehow need to keep track of all observers, you can also release them at will...

A welcome addition to the language could be an UnsubscribeAll() method on the event...

This thread is closed