Single Protocol Reference
public protocol Single<Element> : Subscribable
A Subscribable implementation whereby only a single result is expected to be emitted to the subscriber.
-
Declaration
Swift
@discardableResult func subscribe(_ observer: @escaping Observer) -> any Disposable -
onSuccess(handler:Extension method) 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) -> Disposable where Value == Self.Element.ValueType, Self.Element : ValueExtractorReturn Value
A
Disposablethat can be disposed if the handler is no longer necessary. -
onFailure(handler:Extension method) 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) -> Disposable where ErrorType == Self.Element.ErrorType, Self.Element : ErrorExtractorReturn Value
A
Disposablethat can be disposed if the handler is no longer necessary. -
toAsync()Extension method, asynchronousTransforms this single into an async function that can be awaited on.
Declaration
Swift
func toAsync<Value>() async throws -> Value where Self.Element == Result<Value, any Error>