que es un observable rxjs code example

Example 1: rxjs create observable from value

// Requires RXJS 6+
// Create an observable of any Type
// Ask yourself if the function creates a new observable or not
// If it creates a new one then it is imported from 'rxjs'
// Operators are imported from 'rxjs/operators'
import { of } from 'rxjs';

// T => Observable<T>
const value$ = of(1);

Example 2: rxjs que recibe como parametro un observable

import { Observable } from 'rxjs';const fromEvent = (node, name) => Observable.create((observer) => {  function handler(event) {    observer.next(event)  }  node.addEventListener(name, handler);  return () => {    node.removeEventListener(name, handler);  };});