I'm attempting to transform an array into an observable, following the instructions in the documentation at https://github.com/ReactiveX/rxjs/blob/master/doc/observable.md:
import {Observable} from 'rxjs/Observable';
let dataStream = Observable.from(dataArray);
However, I encounter this error:
TypeError: Observable_1.Observable.from is not a function
My objective is to apply operators like reduce
or scan
on an Observable sequence, as a standard Observable
appears to lack support for this functionality. Here's an example implementation that showcases the issue:
this.dataStream = new Observable(observer => {
// This part works fine
observer.next(dataArray);
});
this.subscription = this.dataStream.reduce(function() {
// This part is never executed
return accumulator;
}).subscribe(result => {
// This part is also never reached
this.finalResult = result;
});
You can find the code snippet on Plnkr: http://plnkr.co/edit/cKEqtp (src/app.ts
).
Thank you!