WatchPublisher

public struct WatchPublisher : Publisher

A publisher that emits a change event each time the remote MongoDB collection changes.

  • Declaration

    Swift

    public typealias Output = AnyBSON
  • Declaration

    Swift

    public typealias Failure = Error
  • Triggers an event when the watch change stream is opened.

    Use this function when you require a change stream to be open before you perform any work. This should be called directly after invoking the publisher.

    Declaration

    Swift

    public func onOpen(_ event: @escaping @Sendable () -> Void) -> Publishers.WatchPublisher

    Parameters

    event

    Callback which will be invoked once the change stream is open.

    Return Value

    A publisher that emits a change event each time the remote MongoDB collection changes.

  • Specifies the scheduler on which to perform subscribe, cancel, and request operations.

    Declaration

    Swift

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

    Parameters

    scheduler

    The scheduler to perform the subscription on.

    Return Value

    A publisher which subscribes on the given scheduler.