I'm trying to skip the very first API call using the skip operator in RxJS . But I am not able to achieve that .
const source = of('a', 'b', 'c', 'd', 'e');
const example = source.pipe(
tap(() => console.log('Service call triggered')), // I'm using a switchMap here to trigger the API call , tap is just for explaining the issue
skip(1)
);
const subscribe = example.subscribe((val) => console.log(val));
In the above example, I'm seeing 5 console.logs
. But I want to see only 4 console.logs
. Could you help, please?
CodePudding user response:
Try below code:
const example = source.pipe(
skip(1),
tap(() => console.log('Service call triggered')),
);
const subscribe = example.subscribe((val) => console.log(val));