Skip to content

RxJS#

1

RxJS is a library for composing asynchronous and event-based programs by using observable sequences.

For#

  • Asynchronous programming
  • Stream

3 way to design#

  • Observer pattern
  • Iterator pattern
  • Functional programming

Observables#

Can be observed, and target can be anything

3 types of notifications

  • next
  • error
  • complete

Observer#

A consumer of values delivered by an Observable

Operators#

Two types of operator#

  • Pipeable Operators
    Can be piped to Observables using the syntax.
  • Creation Operators
    Can be called as standalone functions to create a new Observables.

Commend operators#

Operators

    * Creates an Observable which sequentially emits all values from the first given Observable and then moves on to the next

    concat(args: any[])
    * Filters items from source Observable

    filter<T>((value: T, index: number) => boolean)
    * Creates an Observable from an Array, an array-like object, a Promise, an iterable object, or an Observable-like object

    from<T>(input: ObservableInput<T>)
    * Creates an Observable from listening element

    fromEvent<T>(target: any, eventName: string)
    * Converts data from source Observable, and emits result as an Observable.

    map<T, R>((value: T, index: number) => R)
    * Creates an output Observable which concurrently emits all values from every given input Observable

    merge(args)
    * Converts the arguments to an observable sequence

    of<T>(args)
    * Emits only the first count values emitted by the source Observable.

    take<T>(count: number)