You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a cmd that takes any number of commands or composers (retry, either, etc.).
Upon failure of the first cmd the next one will be called and so on until one of them succeeds.
failure and success would be determined by a predicate callback provided by the caller.
If no predicate is defined, a failure would be anything that throws an error or returns a falsey value.
A default value or an error could be provided as the last argument
If no default value or error is provided, fallback with throw a generic error
Other possible names: failover()
Signature
fallback(cmds, [predicate], [default])
Arguments
cmds: Array of cmds predicate: (optional) callback function that returns a boolean determining if a cmd passed or failed default: (optional) value or error that will be returned or thrown if all commands fail
Proposal
Create a cmd that takes any number of commands or composers (retry, either, etc.).
failure
andsuccess
would be determined by a predicate callback provided by the caller.failure
would be anything that throws an error or returns afalsey
value.Other possible names:
failover()
Signature
fallback(cmds, [predicate], [default])
Arguments
cmds
: Array of cmdspredicate
: (optional) callback function that returns a boolean determining if a cmd passed or faileddefault
: (optional) value or error that will be returned or thrown if all commands failExamples
Complex (maybe unrealistic) caching example
The text was updated successfully, but these errors were encountered: