IoSourceController

open class IoSourceController : Controller

Provides data transfer rate controlled publishing of IO values for IO sources and monitoring of changes in the association state of IO sources.

This controller respects the backpressure strategy of an IO source in order to cope with IO values that are more rapidly produced than specified in the recommended update rate.

Overridden Controller lifecycle methods.

Convenience methods.

  • Schedule the given IO value for publishing on the given IO source. Values to be pulished may be throttled or sampled according to the backpressure strategy and the recommended update rate of the IO source.

    If the given IO source is not associated currently, no publishing takes place. The given IO value is discarded.

    Warning

    If a published value is a reference type (e.g. Object) and if it gets mutated after publishing but before being sent to other actors (e.g. with Throttle strategy), the value received by the associated actor will also reflect the mutated state. This function does not guarantee that the published values stay immutable.

    Declaration

    Swift

    public func publish(source: IoSource, value: Any)

    Parameters

    source

    an IO source object

    value

    an IO value of the given type

  • Listen to update rate changes for the given IO source. The returned observable emits distinct rate values until changed. When the last association becomes disassociated, undefined is emitted. When subscribed, the current update rate is emitted immediately.

    Declaration

    Swift

    public func observeUpdateRate(source: IoSource) -> Observable<Int?>

    Parameters

    source

    an IO source object

  • Listen to associations or disassociations for the given IO source. The returned observable emits distinct boolean values until changed, i.e true when the first association is made and false, when the last association becomes disassociated. When subscribed, the current association state is emitted immediately.

    Declaration

    Swift

    public func observeAssociation(source: IoSource) -> Observable<Bool>

    Parameters

    source

    an IO source object

  • Determines whether the given IO source is currently associated.

    Declaration

    Swift

    public func isAssociated(source: IoSource) -> Bool