class

EventHandler::Subscriptions

Inherits Reference < Object

A bag of Subscriptions that are torn down together. #on adds a tracked subscription and returns it, so a single one can still be re-armed or cancelled individually; #off cancels every remaining one, idempotently.

Instance methods

dispose

dispose/disposed? aliases of #off/#empty?. See Subscription#dispose.

Source
disposed?

:ditto: — whether the bag has been torn down (holds no subscriptions).

Source
empty?

Whether the bag holds no subscriptions.

Source
off

Cancels every tracked subscription and empties the bag. Idempotent.

Source
on(target, type : T.class, once = false, async = ::EventHandler.async?, at = ::EventHandler.at_end, &block : T -> Nil) : Subscription forall T

Subscribes block to type on target, tracking it for a later bulk #off. Returns the created Subscription.

Source