Created
May 3, 2021 09:17
-
-
Save armanozak/bb5f5a854bc5d191e41bb97055aacafc to your computer and use it in GitHub Desktop.
[What's New in RxJS 7] RxJS 7 retry resetOnSuccess #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({ count: 2, resetOnSuccess: true }) | |
) | |
.subscribe({ next: console.log, error: console.warn }); | |
// (synchronously) 1, 2, 3, ERROR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment