How to use the tap function from rxjs

Find comprehensive JavaScript rxjs.tap code examples handpicked from public code repositorys.

31
32
33
34
35
36
37
38
39
40
    ).pipe(swallow())
)

const execute$ = (command, description, args = []) => {
    return terminal$(command, args).pipe(
        tap(({exitCode, stream, value}) => {
            if (exitCode)
                log.debug(msg(`Exit code ${exitCode}`))
            else if (stream === 'stdout')
                log.debug(msg(`stdout\n${value}`))
fork icon45
star icon180
watch icon34

89
90
91
92
93
94
95
96
97
98
        ? cancel$(taskId, 3).pipe(
            map(() => true)
        )
        : of(false)
),
tap(wasRunning =>
    log.info(`EE task ${wasRunning ? 'cancelled' : 'completed'} (${description}, ${taskId})`)
),
catchError(error => {
    log.error(`EE task failed to cancel. Trying again, without loading status first (${description}, ${taskId})`, error)
fork icon45
star icon178
watch icon34

27
28
29
30
31
32
33
34
35
36
    error: error => log.fatal('Pool lock stream failed:', error),
    complete: () => log.fatal('Pool lock stream completed')
})

unlock$.pipe(
    tap(instance => instance.locked = false),
    mergeMap(instance =>
        timer(maxIdleMilliseconds).pipe(
            takeUntil(lock$.pipe(
                filter(currentInstance => currentInstance === instance)
fork icon45
star icon178
watch icon34

+ 13 other calls in file

77
78
79
80
81
82
83
84
85
86

return concat(
    of(initialState),
    progressState$.pipe(
        takeUntil(cancel$.pipe(
            tap(() => finalState$.next(cancelState))
        )),
        catchError(e => concat(finalize$, throwError(() => e)))
    ),
    finalize$,
fork icon45
star icon178
watch icon34

81
82
83
84
85
86
87
88
89
    from(fs.promises.mkdtemp(Path.join(os.tmpdir(), 'test-')))

beforeEach(() =>
    firstValueFrom(
        mkTmpDir$().pipe(
            tap(path => emptyDirPath = path)
        )
    )
)
fork icon45
star icon178
watch icon34

40
41
42
43
44
45
46
47
48
49
}).pipe(
    catchError(error => {
        log.error(msg(id, `could not notify state change: ${state}`), error)
        return EMPTY
    }),
    tap(() =>
        log.trace(() => msg(id, `notified state change: ${state}`))
    ),
    switchMap(() => EMPTY)
)
fork icon45
star icon177
watch icon0

+ 3 other calls in file

643
644
645
646
647
648
649
650
651
652
concatMap((ip_address) =>
    zip([from(ipEvents("ipv4", ip_address, user_id)), from(ipEvents("ipv6", ip_address, user_id))]).pipe(
        rxmap(flatten),
        tap((value) => console.log("size ->", size(value))),
        rxmap(pipe(lofilter(ClickFunnels.utilities.has_ad_id))),
        tap((value) => console.log("size <- ", size(value))),
        concatMap(identity),
        rxmap((event) => ({
            ad_id: pipe(
                paths([["fb_ad_id"], ["h_ad_id"], ["fb_id"], ["ad_id"]]),
fork icon0
star icon0
watch icon1

+ 3 other calls in file

48
49
50
51
52
53
54
55
56
57
const downloadPath = `${downloadUrl}/${setName}/${lang}/data/${filename}`;
let cardSet = await rxjs.lastValueFrom(
  new http.HttpService()
    .get(downloadPath)
    .pipe(
      // rxjs.tap((response) => {console.log(`Request GET: ${downloadPath}`)}),
      rxjs.map((response) => response.data)
    ),
);
if (appendOnly) { // caso seja só append, adiciona o resultado no objeto
fork icon0
star icon0
watch icon0

3
4
5
6
7
8
9
10
11
12
13
// const p2 = e => new Promise(res => res(e))


const f = payload => of(payload)
.pipe(
    delay(1000),
    // tap(e => console.info('before', e)),
    mergeMap(_ => from(p(payload))),
    // tap(e => console.info('after', e)),
    catchError(e => {
        console.error('fn errored', e)
fork icon0
star icon0
watch icon0

+ 5 other calls in file

10
11
12
13
14
15
16
17
18
19
mergeMap(e => {
    if (e.status === 401) {
        // throw new Error(e.statusText)
        return of(1)
            .pipe(
                tap(() => console.info('inside of')),
                map(e => {status = 200; throw new Error('trigger a retry')}),
            )
    }
    return of(e)
fork icon0
star icon0
watch icon0