Import std.events.event
Subscription
class
Public Class Subscription
A handler's place on an Event, which Cancel takes it off. It holds neither the Event nor the handler, so keeping one keeps neither.
Examples
Local ticked = Event<Int>()
Local total = 0
Local onTick = Function(n: Int)
total += n
End Function
Local subscription = ticked.Subscribe(onTick)
Expect(subscription.IsActive)
ticked.Emit(2)
subscription.Cancel()
subscription.Cancel()
ticked.Emit(3)
Expect(total == 2 && !subscription.IsActive)-
Takes the handler off its Event, so no Emit after calls it, and lets go of it. Cancelling it again, or once the Event has gone, does nothing.
-
Whether the handler is still on its Event.
Report an issue with this page or with FutureBlitz on GitHub.