Chain

public class Chain<T>

Chain

Prevents spaghetti code/ pyramid of doom when running multiple asynchronous actions then functions might need to be hard typed if types are not guessable automatically by the compiler.

  • Queues a new command

    Declaration

    Swift

    public func then<U>(command: (T?, U? -> Void) -> Void) -> Chain<U>

    Parameters

    command

    Command to run. First arg is an optinal argument from previous block, second one is the trigger for the tailing block

    Return Value

    Tailing chain

  • Ends chain and starts it immediately after the block

    Declaration

    Swift

    public func endWith(command: T? -> Void)

    Parameters

    command

    Final command to run. Argument is the

  • Starts a new chain

    Declaration

    Swift

    public static func startWith<U>(command: (U? -> Void) -> Void) -> Chain<U>

    Parameters

    command

    Action to run. Argument is the trigger for running tailing block.

    Return Value

    New chain