Which Operator to Use? - Creation Operators
Use this page to find the creation operator implemented by the Observable
type that fits your needs:
I want to create a new sequence | using custom logic | Observable.create | ||
that works like a for-loop | Observable.generate | |||
and emits the values over time | Observable.generateWithRelativeTime | |||
Observable.generateWithAbsoluteTime | ||||
that returns a value | Observable.return/just | |||
multiple times | Observable.repeat | |||
that throws an error | Observable.throw | |||
that completes | Observable.empty | |||
that never does anything | Observable.never | |||
from an event | Observable.fromEvent | |||
that uses custom functions to add and remove event handlers | Observable.fromEventPattern | |||
from an ES6 Promise | Observable.fromPromise | |||
that iterates | over the values in an array |
Observable.fromArray |
||
of object key/values | Observable.pairs | |||
of asynchronous elements | Observable.for | |||
over values in a numeric range | Observable.range | |||
over the values in an iterable, array or array-like object | Observable.from | |||
over arguments | Observable.of | |||
that emits values on a timer | Observable.interval | |||
with an optional initial delay | Observable.timer | |||
that calls a function with no arguments | on a specific scheduler | Observable.start | ||
asynchronously | Observable.startAsync | |||
decided at subscribe-time | based on a boolean condition | Observable.if | ||
from a pre-set set of sequences | Observable.case | |||
using custom logic | Observable.defer | |||
that depends on a resource | Observable.using | |||
I want to wrap a function | and yield the result in a sequence | Observable.toAsync | ||
which accepts a callback | Observable.fromCallback | |||
which accepts a Node.js callback | Observable.fromNodeCallback | |||
I want to combine multiple sequences | and only receive values from the sequence that yields a value first | Observable.amb | ||
and be notified when all of them have finished | Observable.forkJoin | |||
and output the values from all of them | Observable.merge | |||
in order | reusing the latest value when unchanged | Observable.combineLatest | ||
using each value only once | Observable.zip | |||
by subscribing to each in order | when the previous sequence completes | Observable.concat | ||
when the previous sequence errors | Observable.catch | |||
regardless of whether the previous sequence completes or errors | Observable.onErrorResumeNext | |||
by responding to different combinations of values (join calculus) | Observable.when |
See Also
Reference
Concepts