Subject

@propertyWrapper
public class Subject<Element> : BasePublisher<Element>, Subscribable

A Publisher that can be also subscribed to.

You can use it as a property wrapper to make the publishing private in the class where it’s contained, but still expose an Observable to the other classes.

  • The wrapped observable value for property wrapper usage.

    Declaration

    Swift

    public var wrappedValue: Observable<Element> { get }
  • Declaration

    Swift

    public func subscribe(_ observer: @escaping Observer) -> Disposable
  • Subscribes the observer only once and then automatically disposes it.

    This is meant to be used when you only need one observer to be registered once. Use the standalone first() operator if multiple observers all need to register for one event.

    Declaration

    Swift

    @discardableResult
    public func subscribeOnce(_ observer: @escaping Observer) -> Disposable

    Return Value

    a Disposable that can be used to dispose this observer before the first event is sent to the observer, in case it’s not needed any longer.