Inherits from NSObject
Declared in SCExtendedAsyncOpRelationsBuilder.h

Overview

This class contains some methods to control the flow of asynchronous operations of SCExtendedAsyncOp type.
With its help the user can avoid the “callback hell” problem and reduce the depth of asycnhronous calls.

To control the flow of SCAsyncOp operations please consider the SCAsyncOpRelationsBuilder class.
Alternatively, you can convert the operation using the [SCAsyncOpRelationsBuilder operationFromExtendedOperation:] class.

Tasks

  • + sequence:

    Converts operations array to a single operation. The operations will be executed one after another.
    If any operation fails, next ones won’t be executed. The error will be returned in the callback.
    On success the callback receives the result of the last operation.

  • + stopOnFirstSuccessInSequence:

    Executes operations in array one after another until one of them succeeds.

  • + group:

    Converts operations array to a single operation. The operations will be executed in parallel.
    A callback will be called after all operations are finished.
    If any operation fails, next ones will be executed. However, an error of the failed operation will be returned in the callback.
    On success the callback receives an array of single operation results.

  • + stopOnFirstErrorInGroup:

    Converts operations array to a single operation. The operations will be executed in parallel.
    If any operation fails, others are cancelled immediately. The error will be returned in the callback.
    On success the callback receives an array of single operation results.

  • + waterfallForOperation:chainingCallbacks:

    Converts operations array to a single operation. The operations will be executed one after another. The result of each operation will be passed to the next one.
    If any operation fails, next ones won’t be executed. The error will be returned in the callback.
    On success the callback receives the result of the last operation.

  • + waterfallUntilSuccessForOperation:chainingCallbacks:

    Converts operations array to a single operation. Executes operations in array one after another until one of them succeeds. Error of each operation is forwarded to the next one until some operation succeeds.

Class Methods

group:

Converts operations array to a single operation. The operations will be executed in parallel.
A callback will be called after all operations are finished.
If any operation fails, next ones will be executed. However, an error of the failed operation will be returned in the callback.
On success the callback receives an array of single operation results.

+ (SCExtendedAsyncOp)group:(NSArray *)operations

Parameters

operations
  • NSArray of SCExtendedAsyncOp objects

Return Value

a single SCExtendedAsyncOp as a combination

SCExtendedAsyncOpRelationsBuilder group: @[a, b, c, d, e]
{
// when “c” and “e” failed
// then a, b, d are still running
// and result == nil
// error is non determined. It may be either c.error or e.error
} );

Discussion

Converts operations array to a single operation. The operations will be executed in parallel.
A callback will be called after all operations are finished.
If any operation fails, next ones will be executed. However, an error of the failed operation will be returned in the callback.
On success the callback receives an array of single operation results.

Declared In

SCExtendedAsyncOpRelationsBuilder.h

sequence:

Converts operations array to a single operation. The operations will be executed one after another.
If any operation fails, next ones won’t be executed. The error will be returned in the callback.
On success the callback receives the result of the last operation.

+ (SCExtendedAsyncOp)sequence:(NSArray *)operations

Parameters

operations
  • NSArray of SCExtendedAsyncOp objects

Return Value

a single SCExtendedAsyncOp as a combination

Discussion

Converts operations array to a single operation. The operations will be executed one after another.
If any operation fails, next ones won’t be executed. The error will be returned in the callback.
On success the callback receives the result of the last operation.

Declared In

SCExtendedAsyncOpRelationsBuilder.h

stopOnFirstErrorInGroup:

Converts operations array to a single operation. The operations will be executed in parallel.
If any operation fails, others are cancelled immediately. The error will be returned in the callback.
On success the callback receives an array of single operation results.

+ (SCExtendedAsyncOp)stopOnFirstErrorInGroup:(NSArray *)operations

Parameters

operations
  • NSArray of SCExtendedAsyncOp objects

Return Value

a single SCExtendedAsyncOp as a combination

Discussion

Converts operations array to a single operation. The operations will be executed in parallel.
If any operation fails, others are cancelled immediately. The error will be returned in the callback.
On success the callback receives an array of single operation results.

Declared In

SCExtendedAsyncOpRelationsBuilder.h

stopOnFirstSuccessInSequence:

Executes operations in array one after another until one of them succeeds.

+ (SCExtendedAsyncOp)stopOnFirstSuccessInSequence:(NSArray *)operations

Parameters

operations
  • NSArray of SCExtendedAsyncOp objects

Return Value

a single SCExtendedAsyncOp as a combination

Discussion

Executes operations in array one after another until one of them succeeds.

Declared In

SCExtendedAsyncOpRelationsBuilder.h

waterfallForOperation:chainingCallbacks:

Converts operations array to a single operation. The operations will be executed one after another. The result of each operation will be passed to the next one.
If any operation fails, next ones won’t be executed. The error will be returned in the callback.
On success the callback receives the result of the last operation.

+ (SCExtendedAsyncOp)waterfallForOperation:(SCExtendedAsyncOp)firstOperation chainingCallbacks:(NSArray *)chainingCallbacks

Parameters

firstOperation
  • the first operation of SCExtendedAsyncOp type.
chainingCallbacks
  • NSArray of SCExtendedOpChainUnit. Each of them takes the result of a previous operation and constructs a single SCExtendedAsyncOp

Return Value

a single SCExtendedAsyncOp as a combination

Discussion

Converts operations array to a single operation. The operations will be executed one after another. The result of each operation will be passed to the next one.
If any operation fails, next ones won’t be executed. The error will be returned in the callback.
On success the callback receives the result of the last operation.

Declared In

SCExtendedAsyncOpRelationsBuilder.h

waterfallUntilSuccessForOperation:chainingCallbacks:

Converts operations array to a single operation. Executes operations in array one after another until one of them succeeds. Error of each operation is forwarded to the next one until some operation succeeds.

+ (SCExtendedAsyncOp)waterfallUntilSuccessForOperation:(SCExtendedAsyncOp)firstOperation chainingCallbacks:(NSArray *)chainingCallbacks

Parameters

firstOperation
  • the first operation of SCExtendedAsyncOp type.
chainingCallbacks
  • NSArray of SCExtendedOpChainUnit. Each of them takes the result of a previous operation and constructs a single SCExtendedAsyncOp

Return Value

a single SCExtendedAsyncOp as a combination

Discussion

Converts operations array to a single operation. Executes operations in array one after another until one of them succeeds. Error of each operation is forwarded to the next one until some operation succeeds.

Declared In

SCExtendedAsyncOpRelationsBuilder.h