Skip to content

Instantly share code, notes, and snippets.

@armanozak
Created May 3, 2021 09:17
Show Gist options
  • Save armanozak/bb5f5a854bc5d191e41bb97055aacafc to your computer and use it in GitHub Desktop.
Save armanozak/bb5f5a854bc5d191e41bb97055aacafc to your computer and use it in GitHub Desktop.
[What's New in RxJS 7] RxJS 7 retry resetOnSuccess #blog #rxjs
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