Skip to content

Instantly share code, notes, and snippets.

@NetanelBasal
Last active October 30, 2022 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NetanelBasal/ac7f6e3e6fe6ce935e72aade00f6a0f5 to your computer and use it in GitHub Desktop.
Save NetanelBasal/ac7f6e3e6fe6ce935e72aade00f6a0f5 to your computer and use it in GitHub Desktop.
import { repeat, filter, take, timer } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class FooService {
private http = inject(HttpClient);
doSometing(data) {
return this.http.post('https://foo', data)
.pipe(
// 👇👇👇
repeat({ delay: (count) => timer(count * 1000) }),
filter((res) => res.status === 'completed'),
take(1)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment