FutureType

public protocol FutureType

Generic Future Type

  • Type of the Element delivered with the below mentioned event upon .completed

    Declaration

    Swift

    associatedtype Element
  • Register a callback/continuation block for when the Future fulfills.

    Note

    this prevents blocking execution of calling thread, the callback is invoked from the producing thread/queue

    Declaration

    Swift

    func on(event block: @escaping Consumer<FutureEvent<Element>>)

    Parameters

    block

    The callback to invoke when the event has become available

  • Cancel the execution (when possible)

    Declaration

    Swift

    func cancel(mayInterruptIfRunning flag: Bool) -> Bool

    Parameters

    flag

    whether to send an interrupt to the executing thread when already executing

    Return Value

    false when the task could not be cancelled, true when cancelled successfully

  • Whether the execution is done (E.g. fulfilled, failed or cancelled)

    Declaration

    Swift

    var done: Bool { get }
  • unit(_:) Extension method

    Unit future that wraps a concrete value into a .completed FutureEvent

    Declaration

    Swift

    public static func unit<A>(_ value: A) -> Future<A>

    Return Value

    a completed Future