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.Throws
The genericFailureemitted by the underlyingSingle, or aCancellationErrorif the Single completes before emitting theResult.Declaration
Swift
func toAsync<Value, Failure>() async throws -> Value where Element == Result<Value, Failure>, Failure : ErrorReturn Value
The generic
Valueemitted by the underlyingSingle.
View on GitHub