Guarantee

public final class Guarantee<T> : Thenable

A Guarantee is a functional abstraction around an asynchronous operation that cannot error.

See

Thenable
  • Returns a Guarantee sealed with the provided value.

    Declaration

    Swift

    public static func value(_ value: T) -> Guarantee<T>
  • Returns a pending Guarantee that can be resolved with the provided closure’s parameter.

    Declaration

    Swift

    public init(resolver body: (@escaping(T) -> Void) -> Void)
  • See

    Thenable.pipe

    Declaration

    Swift

    public func pipe(to: @escaping(Result<T, Error>) -> Void)
  • Declaration

    Swift

    public var result: Result<T, Error>? { get }
  • Returns a tuple of a pending Guarantee and a function that resolves it.

    Declaration

    Swift

    public class func pending() -> (guarantee: Guarantee<T>, resolve: (T) -> Void)
  • Undocumented

    Declaration

    Swift

    @discardableResult
    func done(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ body: @escaping(T) -> Void) -> Guarantee<Void>
  • Undocumented

    Declaration

    Swift

    func get(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ body: @escaping (T) -> Void) -> Guarantee<T>
  • Undocumented

    Declaration

    Swift

    func map<U>(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ body: @escaping(T) -> U) -> Guarantee<U>
  • Undocumented

    Declaration

    Swift

    @discardableResult
    func then<U>(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ body: @escaping(T) -> Guarantee<U>) -> Guarantee<U>
  • Undocumented

    Declaration

    Swift

    func thenMap<U>(on: DispatchQueue? = .pmkDefault, flags: DispatchWorkItemFlags? = nil, _ transform: @escaping(T.Iterator.Element) -> Guarantee<U>) -> Guarantee<[U]>
  • Undocumented

    Declaration

    Swift

    @discardableResult
    func done(on: Dispatcher = conf.D.return, _ body: @escaping(T) -> Void) -> Guarantee<Void>
  • Undocumented

    Declaration

    Swift

    func get(on: Dispatcher = conf.D.return, _ body: @escaping (T) -> Void) -> Guarantee<T>
  • Undocumented

    Declaration

    Swift

    func map<U>(on: Dispatcher = conf.D.map, _ body: @escaping(T) -> U) -> Guarantee<U>
  • Undocumented

    Declaration

    Swift

    @discardableResult
    func then<U>(on: Dispatcher = conf.D.map, _ body: @escaping(T) -> Guarantee<U>) -> Guarantee<U>
  • Undocumented

    Declaration

    Swift

    func asVoid() -> Guarantee<Void>
  • Blocks this thread, so you know, don’t call this on a serial thread that any part of your chain may use. Like the main thread for example.

    Declaration

    Swift

    func wait() -> T
  • Guarantee<[T]> => T -> Guarantee<U> => Guarantee<[U]>

    firstly {
        .value([1,2,3])
    }.thenMap {
        .value($0 * 2)
    }.done {
        // $0 => [2,4,6]
    }
    

    Declaration

    Swift

    func thenMap<U>(on: Dispatcher = conf.D.map, _ transform: @escaping(T.Iterator.Element) -> Guarantee<U>) -> Guarantee<[U]>