Skip to main content

What's the difference between "pipeable" and "creation" operators?

RxJS has two types of operators:


1. Creation Operators

Create a new Observable from scratch.

Examples:

  • of(1, 2, 3)
  • from([10, 20, 30])
  • interval(1000)
  • timer(2000)
  • fromEvent(button, 'click')

They say: "Start the stream here."


2. Pipeable Operators

Process data inside an already existing stream. You use them inside .pipe(...).

Examples:

  • map(x => x * 2)
  • filter(x => x > 10)
  • take(3)
  • debounceTime(300)
  • switchMap(...)

They say: "Once the stream is flowing, change it, slow it down, pick what you need."


Example together:

ts
import { of } from 'rxjs'; import { map, filter } from 'rxjs/operators'; of(1, 2, 3, 4) // ← creation operator .pipe( // ← pipeable operators filter(x => x % 2 === 0), map(x => x * 10) ) .subscribe(console.log);

Conclusion:

TypeWhat it doesWhere it's used
CreationCreates a streamof(), from(), interval()
PipeableChanges a streaminside .pipe(...)

One starts the river. The other sets up filters and bends.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.