RxJS is one of the latest libraries in web development. Offering a powerful, functional approach for dealing with events and with integration points into a growing number of frameworks, libraries, and utilities,

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

Observable Stream

  • – User Input
  • – Http Request
  • – Array
  • – Object

Observable Handle

  • – Data
  • – Error
  • – Completion

We can handle observable through of subscribe with three methods data,error and complete,

(data) => console.log(data),
(error) => console.log(error),
() => console.log("Complete")

1- fromEvent

import {fromEvent} from 'rxjs'
fromEvent(this.addBtn.nativeElement,'click').subscribe((res)=> {console.log(res)})


Example RxJS :- timer,interval,unsubscribe