Skip to content

Instantly share code, notes, and snippets.

@NetanelBasal
Last active October 30, 2022 13:49
Show Gist options
  • Save NetanelBasal/ac7f6e3e6fe6ce935e72aade00f6a0f5 to your computer and use it in GitHub Desktop.
Save NetanelBasal/ac7f6e3e6fe6ce935e72aade00f6a0f5 to your computer and use it in GitHub Desktop.

Revisions

  1. NetanelBasal revised this gist Oct 30, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion repeat-3.ts
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ export class FooService {
    .pipe(
    // πŸ‘‡πŸ‘‡πŸ‘‡
    repeat({ delay: (count) => timer(count * 1000) }),
    filter((res) => res.success),
    filter((res) => res.status === 'completed'),
    take(1)
    )
    }
  2. NetanelBasal created this gist Oct 30, 2022.
    16 changes: 16 additions & 0 deletions repeat-3.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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.success),
    take(1)
    )
    }
    }