Single
public class Single<Element> : Subscribable
A Subscribable implementation whereby only a single result is expected to be emitted to the subscriber.
-
Declaration
Swift
@discardableResult public func subscribe<O>(_ observer: O) -> any Disposable where Element == O.Element, O : Observer -
Subscribe an handler to this
Singlewhich will be called at most once if theSingleis successful.Declaration
Swift
@discardableResult func onSuccess<Value>(handler: @escaping (_ output: Value) -> Void) -> any Disposable where Element : ValueExtractor, Value == Element.ValueTypeReturn Value
A
Disposablethat can be disposed if the handler is no longer necessary. -
Subscribe an handler to this
Singlewhich will be called at most once if theSingleis unsuccessful.Declaration
Swift
@discardableResult func onFailure<ErrorType>(handler: @escaping (_ error: ErrorType) -> Void) -> any Disposable where Element : ErrorExtractor, ErrorType == Element.ErrorTypeReturn Value
A
Disposablethat can be disposed if the handler is no longer necessary. -
toAsync()AsynchronousTransforms this single into an async function that can be awaited on.
Declaration
Swift
func toAsync<Value>() async throws -> Value where Element == Result<Value, any Error>
View on GitHub