share
Comparte el Observable fuente entre varios suscriptores
Descripción
Ejemplos
import { map, mergeAll, take, tap } from "rxjs/operators";
import { ajax } from "rxjs/ajax";
const ghibliFilm$ = ajax.getJSON("https://ghibliapi.herokuapp.com/films").pipe(
tap((_) => console.log("Nueva petición")),
mergeAll(),
take(1)
);
const ghibliFilmTitle$ = ghibliFilm$.pipe(map(({ title }) => title));
const ghibliFilmDescription$ = ghibliFilm$.pipe(
map(({ description }) => description)
);
ghibliFilmTitle$.subscribe(console.log);
ghibliFilmDescription$.subscribe(console.log);
/* Salida:
'Nueva petición'
'Castle in the Sky',
'Nueva petición',
'The orphan Sheeta inherited a mysterious crystal that links her to the mythical...'
*/Recursos adicionales
Last updated
