btroncone / learn-rxjs

Clear examples, explanations, and resources for RxJS

Home Page:https://www.learnrxjs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`do` operator example does not use `do`

jonbeller opened this issue · comments

In https://github.com/btroncone/learn-rxjs/blob/master/operators/utility/do.md, here is the example code:

import { of } from 'rxjs/observable/of';
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));

do is referenced in the comments, but not the code.

Ah I see above the code it notes If you are using as a pipeable operator, do is known as tap!

@jonbeller Yep, sorry about that! I'm adding it to the heading as well to hopefully avoid confusion in the future. 👍