rxjs
of
Rof(): Observable<any>{
return of(1,2,3,4)
}
Tof(){
this.Rof().subscribe(
next => console.log(‘next:‘, next),
err => console.log(‘error:‘, err),
() => console.log(‘the end‘),
);
}
/*
next: 1
next: 2
next: 3
the end
*/
from
RFrom(): Observable<any>{
return from([10, 20, 30], asyncScheduler)
}
TFrom(){
this.RFrom().subscribe(
next => console.log(‘next:‘, next),
err => console.log(‘error:‘, err),
() => console.log(‘the end‘),
);
}
/*
next: 10
next: 20
next: 30
the end
*/