• fallback takes an array of Tasks and uses it as a fallback plan. For each value in the array, if it doesn't resolve to a successful value, the fallback plan will try the next.

    This returns a Promise that resolves to the successful value or rejects with the final error in the plan.

    Example

    Using the fallback-plan, the code in the docs could be rewritten:

    fallback([
    () => getRemoteResource('foo'),
    () => getRemoteResource('foo2'),
    () => getLocalResource('foo3'),
    () => getDefault()
    ]).then(useResource);

    Actually, you could go a step further, since the call to getDefault has no parameters:

    fallback([
    () => getRemoteResource('foo'),
    () => getRemoteResource('foo2'),
    () => getLocalResource('foo3'),
    getDefault
    ]).then(useResource);

    since fallback handles:

    • plain values
    • Promises that resolve a value
    • functions that return Promises
    • functions that return a value

    Type Parameters

    • R

    Parameters

    • tasks: Task<R, []>[]

      the Tasks that you want in your plan; none of these can take any parameter

    Returns Promise<R>

Generated using TypeDoc