of
Convierte los argumentos en una secuencia Observable
Last updated
import { of } from "rxjs";
const framework$ = of("Angular", "React", "Vue");
framework$.subscribe(console.log);
// Salida: Angular, React, Vueimport { of } from "rxjs";
const fruit$ = of(["Fresa", "Cereza"], ["Limón", "Naranja"]);
fruit$.subscribe((fruit) => console.log(fruit));
// Salida: ["Fresa", "Cereza"] ["Limón", "Naranja"]import { of } from "rxjs";
const iceCream$ = of(
{ size: "Grande", toppings: ["Galletas Oreo", "Sirope de Chocolate"] },
{ size: "Pequeño", toppings: ["Fresas"] }
);
iceCream$.subscribe(console.log);
// Salida: { size: "Grande", toppings: ["Galletas Oreo", "Sirope de Chocolate"] } { size: "Pequeño", toppings: ["Fresas"] }import { of } from "rxjs";
of(10, 20, 30).subscribe(
(next) => console.log("next:", next),
(err) => console.log("error:", err),
() => console.log("Fin")
);
// Salida:
// 'next: 10'
// 'next: 20'
// 'next: 30'
// 'Fin'import { of } from "rxjs";
of([1, 2, 3]).subscribe(
(next) => console.log("next:", next),
(err) => console.log("error:", err),
() => console.log("Fin")
);
// Salida:
// 'next: [1,2,3]'
// 'Fin'