class EventHandler::Subscriptions

Overview

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.

Defined in:

subscription.cr

Instance Method Summary

Instance Method Detail

def dispose : Nil #

[View source]
def disposed? : Bool #

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


[View source]
def empty? : Bool #

Whether the bag holds no subscriptions.


[View source]
def off : Nil #

Cancels every tracked subscription and empties the bag. Idempotent.


[View source]
def 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.


[View source]