ActionSubscription

public struct ActionSubscription

Subscription structure that represents a listener subscription. When adding a listener you get a subscription back. You can use this subscription to remove the listener, notify about the current state or link the listener lifecycle with an object.

  • Remove the listner associated with this subscription. After calling removeListener the listener won’t be notified anymore.

    Example

    let subscription = store.addActionListener(...)
    subscription.removeListener()
    

    Declaration

    Swift

    public func removeListener()
  • Link the listener associated with this subscription with an object. When the object gets deallocated the listener is removed. Useful when adding listeners that updates a UIView. You can link the listener lifecycle to the UIView’s lifecycle. When the UIView is removed (deallocated) the listener will be removed and will stop it from being notified.

    Example

    let view = SomeUIVIew()
    
    // Listener updates the view
    let subscription = store.addActionListener(...)
    
    // Link the listener lifecycle to the view. No need to manually call `removeListener` anymore.
    subscription.linkLifeCycleTo(object: view)
    

    Declaration

    Swift

    public func linkLifeCycleTo(object: NSObject)