Observer
public final class Observer<Value, Error: Swift.Error>
An Observer is a simple wrapper around a function which can receive Events (typically from a Signal).
-
An action that will be performed upon arrival of the event.
Declaration
Swift
public let action: Action -
An initializer that accepts a closure accepting an event for the observer.
Declaration
Swift
public init(_ action: @escaping Action)Parameters
actionA closure to lift over received event.
-
An initializer that accepts closures for different event types.
Declaration
Swift
public convenience init( value: ((Value) -> Void)? = nil, failed: ((Error) -> Void)? = nil, completed: (() -> Void)? = nil, interrupted: (() -> Void)? = nil )Parameters
valueOptional closure executed when a
valueevent is observed.failedOptional closure that accepts an
Errorparameter when a failed event is observed.completedOptional closure executed when a
completedevent is observed.interrupedOptional closure executed when an
interruptedevent is observed. -
Puts a
valueevent intoself.Declaration
Swift
public func send(value: Value)Parameters
valueA value sent with the
valueevent. -
Puts a failed event into
self.Declaration
Swift
public func send(error: Error)Parameters
errorAn error object sent with failed event.
-
Puts a
completedevent intoself.Declaration
Swift
public func sendCompleted() -
Puts an
interruptedevent intoself.Declaration
Swift
public func sendInterrupted()
View on GitHub
Install in Dash
Observer Class Reference