如何使用 RxJS 跳过运算符跳过 API 调用?

How to Skip the API call using RxJS skip operator?

我正在尝试使用 RxJS 中的 skip 运算符跳过第一个 API 调用。但是我做不到。

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));

在上面的示例中,我看到 5 console.logs 。但我只想看到 4 console.logs 。你能帮忙吗?

Stackblitz

试试下面的代码:

const example = source.pipe(
  skip(1),
  tap(() => console.log('Service call triggered')), 
);

const subscribe = example.subscribe((val) => console.log(val));