Goals

  • Learn about higher-order Observables.
  • Learn how to use the Pipe operator to create a custom operator.
  • Learn how to create a custom operator without existing operators.

Custom Operators

Creating custom operators have several benefits:

  1. Encapsulation of logic into a single function.
  2. Reusable with any Observable.
  3. Distributable if necessary.

Creating a Custom Operator

There are two distinct approaching for creating a custom RxJS operator:

  1. Use the pipe() function to create a new operator using existing operators.
  2. Create a higher-order function that returns a function that is invoked with the source Observable and returns a new Observable.

Each approach has advantages and disadvantages.

First, the pipe() function is a simpler approach to creating a new custom operator. By using existing operators we can encapsulate the necessary behavior and logic into a new operator. RxJS provides many operators that are at our disposal, and it is probably likely that we can create our new custom operator by using one more of existing operators to achieve the desired result.

Custom Operators

Goals

  • Learn about higher-order Observables.
  • Learn how to use the Pipe operator to create a custom operator.
  • Learn how to create a custom operator without existing operators.

Custom Operators

Creating custom operators have several benefits:

  1. Encapsulation of logic into a single function.
  2. Reusable with any Observable.
  3. Distributable if necessary.

Creating a Custom Operator

There are two distinct approaching for creating a custom RxJS operator:

  1. Use the pipe() function to create a new operator using existing operators.
  2. Create a higher-order function that returns a function that is invoked with the source Observable and returns a new Observable.

Each approach has advantages and disadvantages.

First, the pipe() function is a simpler approach to creating a new custom operator. By using existing operators we can encapsulate the necessary behavior and logic into a new operator. RxJS provides many operators that are at our disposal, and it is probably likely that we can create our new custom operator by using one more of existing operators to achieve the desired result.

Copyright

Site © by LiveLoveApp, LLC

We Can Help!

Need help with RxJS in your project?

Hire Us