差异Rxjs和.pipe [重复]

问题描述 投票:0回答:2

这个问题在这里已有答案:

有人可以解释一下rxjs和.pipe之间的区别吗?

每个例子都有助于理解这两种情况。在什么情况下我们可以使用每个案例?

rxjs pipe
2个回答
0
投票

Rxjs是javascript official doc的反应式扩展库

。管理它的库example of native js pipeofficial rxjs docs的功能

Web to learn rxjs


0
投票
  • RxJs是一个图书馆。根据RxJs文档 -

RxJs是一个使用observable进行反应式编程的库,可以更容易地组合异步或基于回调的代码

  • Pipe是RxJs的一个特性。根据Angular文档 -

管道允许您将多个功能组合到一个功能中。 pipe()函数将要组合的函数作为其参数,并返回一个新函数,该函数在执行时按顺序运行组合函数。

管道在行动 -

import { filter, map } from 'rxjs/operators';

const squareOdd = of(1, 2, 3, 4, 5)
  .pipe(
    filter(n => n % 2 !== 0),
    map(n => n * n)
  );

// Subscribe to get values
squareOdd.subscribe(x => console.log(x));
© www.soinside.com 2019 - 2024. All rights reserved.