Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
2.9 KB
|
Line | |
---|
1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { from, of } from 'rxjs';
|
---|
9 | import { map, switchMap } from 'rxjs/operators';
|
---|
10 | /**
|
---|
11 | * Perform a side effect through a switchMap for every emission on the source Observable,
|
---|
12 | * but return an Observable that is identical to the source. It's essentially the same as
|
---|
13 | * the `tap` operator, but if the side effectful `next` function returns an ObservableInput,
|
---|
14 | * it will wait before continuing with the original value.
|
---|
15 | */
|
---|
16 | export function switchTap(next) {
|
---|
17 | return switchMap(v => {
|
---|
18 | const nextResult = next(v);
|
---|
19 | if (nextResult) {
|
---|
20 | return from(nextResult).pipe(map(() => v));
|
---|
21 | }
|
---|
22 | return of(v);
|
---|
23 | });
|
---|
24 | }
|
---|
25 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3dpdGNoX3RhcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3JvdXRlci9zcmMvb3BlcmF0b3JzL3N3aXRjaF90YXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLElBQUksRUFBNkMsRUFBRSxFQUFDLE1BQU0sTUFBTSxDQUFDO0FBQ3pFLE9BQU8sRUFBQyxHQUFHLEVBQUUsU0FBUyxFQUFDLE1BQU0sZ0JBQWdCLENBQUM7QUFFOUM7Ozs7O0dBS0c7QUFDSCxNQUFNLFVBQVUsU0FBUyxDQUFJLElBQXlDO0lBRXBFLE9BQU8sU0FBUyxDQU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