Skip to content

Commit

Permalink
fix: Adding docs about fallback parameters (#460)
Browse files Browse the repository at this point in the history
fixes #459
  • Loading branch information
helio-frota authored Sep 11, 2020
1 parent 2d4318d commit e8989b6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ the `open` state.
When a fallback function is triggered, it's considered a failure, and the
fallback function will continue to be executed until the breaker is closed.

The fallback function accepts the same parameters as the fire function:

```javascript
const delay = (delay, a, b, c) =>
new Promise((resolve) => {
setTimeout(() => {
resolve();
}, delay);
});

const breaker = new CircuitBreaker(delay);
breaker.fire(20000, 1, 2, 3);
breaker.fallback((delay, a, b, c) => `Sorry, out of service right now. But your parameters are: ${delay}, ${a}, ${b} and ${c}`);
```

### Browser

Opossum really shines in a browser. You can use it to guard against network
Expand Down

0 comments on commit e8989b6

Please sign in to comment.