RxJs : tap/do

Description: API / rxjs/operators
Transparently perform actions or side-effects, such as logging

import of } from 'rxjs';
import { tap, map from 'rxjs/operators';

const source = of(1, 2, 3, 4, 5);
//transparently log values from source with 'do'
const example = source.pipe(
    tap(val => console.log(`BEFORE MAP: ${val}`)),
    map(val => val + 10),
    tap(val => console.log(`AFTER MAP: ${val}`))
);
//'do' does not transform values
//output: 11...12...13...14...15
const subscribe = example.subscribe(val => console.log(val));

22 Replies to “RxJs : tap/do”

  1. If you want to use the photo it would also be good to check with the artist beforehand in case it is subject to copyright. Best wishes. Aaren Reggis Sela

  2. I have read so many articles or reviews about the blogger lovers except this article is actually a pleasant piece of writing, keep it up. Claudine Grannie Isador

  3. Please message me with some pointers on how you made this website look like this, Id appreciate it. Charmian Brien Cyrano

  4. Ich werde die Illuminaten finden und for das Vatikan-Gericht stellen. Und wenn es das letzte ist , was ich tue. Lotti Geoff Callahan

  5. You really make it seem so easy with your presentation but I find this matter to be actually something which I think I would never understand. Maxi Ransom Ulberto

  6. There is clearly a lot to realize about this. I suppose you made some good points in features also. Lindie Archambault Omari

  7. You completed a few nice points there. I did a search on the topic and found nearly all people will go along with with your blog. Xylina Aristotle Allen

Comments are closed.