Async

public protocol Async : MonadDefer

Async models how a data type runs an asynchronous computation that may fail, described by the Proc signature.

  • Suspends side effects in the provided registration function. The parameter function is injected with a side-effectful callback for signaling the result of an asynchronous process.

    Declaration

    Swift

    static func asyncF<A>(_ procf: @escaping ProcF<Self, E, A>) -> Kind<Self, A>

    Parameters

    procf

    Asynchronous operation.

    Return Value

    A computation describing the asynchronous operation.

  • Switches the evaluation of a computation to a different DispatchQueue.

    Declaration

    Swift

    static func continueOn<A>(
        _ fa: Kind<Self, A>,
        _ queue: DispatchQueue) -> Kind<Self, A>

    Parameters

    fa

    A computation.

    queue

    A Dispatch Queue.

    Return Value

    A computation that will run on the provided queue.

  • async(_:) Extension method

    Suspends side effects in the provided registration function. The parameter function is injected with a side-effectful callback for signaling the result of an asynchronous process.

    Declaration

    Swift

    static func async<A>(_ proc: @escaping Proc<E, A>) -> Kind<Self, A>

    Parameters

    proc

    Asynchronous operation.

    Return Value

    A computation describing the asynchronous operation.

  • defer(_:_:) Extension method

    Provides a computation that evaluates the provided function on every run.

    Declaration

    Swift

    static func `defer`<A>(
        _ queue: DispatchQueue,
        _ f: @escaping () -> Kind<Self, A>) -> Kind<Self, A>

    Parameters

    queue

    Dispatch queue which the computation must be sent to.

    f

    Function returning a value.

    Return Value

    A computation that defers the execution of the provided function.

  • later(_:_:) Extension method

    Provides a computation that evaluates the provided function on every run.

    Declaration

    Swift

    static func later<A>(
        _ queue: DispatchQueue,
        _ f: @escaping () throws -> A) -> Kind<Self, A>

    Parameters

    queue

    Dispatch queue which the computation must be sent to.

    f

    Function returning a value.

    Return Value

    A computation that defers the execution of the provided function.

  • delayOrRaise(_:_:) Extension method

    Provides a computation that evaluates the provided function on every run.

    Declaration

    Swift

    static func delayOrRaise<A>(
        _ queue: DispatchQueue,
        _ f: @escaping () -> Either<E, A>) -> Kind<Self, A>

    Parameters

    queue

    Dispatch queue which the computation must be sent to.

    f

    A function that provides a value or an error.

    Return Value

    A computation that defers the execution of the provided value.

  • never() Extension method

    Provides an asynchronous computation that never finishes.

    Declaration

    Swift

    static func never<A>() -> Kind<Self, A>

    Return Value

    An asynchronous computation that never finishes.