Skip to content
FutureBlitz

    Install

    Import std.events.event

    Subscription

    std.events.event

    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)

    std/events/event.fb, line 240

    • Public Method Cancel() method #

      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.

    • Public Property IsActive: Bool property #

      Whether the handler is still on its Event.

    Report an issue with this page or with FutureBlitz on GitHub.