Skip to content

Instantly share code, notes, and snippets.

@oleh-zaporozhets
Created October 23, 2021 18:47
Show Gist options
  • Select an option

  • Save oleh-zaporozhets/49ea07a87d31dedbc4165bba2ebab096 to your computer and use it in GitHub Desktop.

Select an option

Save oleh-zaporozhets/49ea07a87d31dedbc4165bba2ebab096 to your computer and use it in GitHub Desktop.
...
private interceptErrorResponse(error: any) {
const shouldCircuitBreakerBeOpen = this.errorHandler(error);
if (shouldCircuitBreakerBeOpen && !this.isOpen) {
this.openCircuitBreaker();
}
return Promise.reject(error);
}
private openCircuitBreaker() {
this.isOpen = true;
setTimeout(() => {
this.isOpen = false;
}, this.timeout);
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment