Value

public struct Value<Subscribable> : Publisher where Subscribable : RealmSubscribable, Subscribable : ThreadConfined

A publisher which emits an object or collection each time that object is mutated.

  • This publisher can only fail due to resource exhaustion when creating the worker thread used for change notifications.

    Declaration

    Swift

    public typealias Failure = Error
  • This publisher emits the object or collection which it is publishing.

    Declaration

    Swift

    public typealias Output = Subscribable
  • Specifies the scheduler on which to perform subscribe, cancel, and request operations.

    For Realm Publishers, this determines which queue the underlying change notifications are sent to. If receive(on:) is not used subsequently, it also will determine which queue elements received from the publisher are evaluated on. Currently only serial dispatch queues are supported, and the options: parameter is not supported.

    Declaration

    Swift

    public func subscribe<S>(on scheduler: S) -> Value<Subscribable> where S : Scheduler

    Parameters

    scheduler

    The serial dispatch queue to perform the subscription on.

    Return Value

    A publisher which subscribes on the given scheduler.

  • Specifies the scheduler on which to perform downstream operations.

    This differs from subscribe(on:) in how it is integrated with the autorefresh cycle. When using subscribe(on:), the subscription is performed on the target scheduler and the publisher will emit the collection during the refresh. When using receive(on:), the collection is then converted to a ThreadSafeReference and delivered to the target scheduler with no integration into the autorefresh cycle, meaning it may arrive some time after the refresh occurs.

    When in doubt, you probably want subscribe(on:).

    Declaration

    Swift

    public func receive<S>(on scheduler: S) -> Publishers.Handover<`Self`, S> where S : Scheduler

    Parameters

    scheduler

    The serial dispatch queue to receive values on.

    Return Value

    A publisher which delivers values to the given scheduler.