Created
May 3, 2021 09:16
-
-
Save armanozak/ac549b9d79df8aa8dcb41a221ef87c7b to your computer and use it in GitHub Desktop.
[What's New in RxJS 7] RxJS 6 retry #blog #rxjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defer, from } from "rxjs"; | |
import { retry, tap } from "rxjs/operators"; | |
const values = ["_", 0, 1, 0, 2, 0, 3, 0, 0, 0, 4]; | |
defer(() => { | |
values.shift(); | |
return from(values); | |
}) | |
.pipe( | |
tap(i => { | |
if (!i) throw "ERROR"; | |
}), | |
retry(2) | |
) | |
.subscribe({ next: console.log, error: console.warn }); | |
// (synchronously) 1, ERROR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment