Sto utilizzando questo tutorial https://egghead.io/lessons/rxjs-creating-an-observable che fa riferimento alla versione 2.5.2 di rxjs.ottenere errori rxjs quando si fa riferimento all'ultima versione rxjs
sto riferimento a l'ultimo rx.umd.js
da [email protected]"
pacchetto NPM <script src="node_modules/rxjs/bundles/rx.umd.js"></script>
E qui è il codice che sto cercando di eseguire:
console.clear();
var source = Rx.Observable.create(function(observer){
setTimeout(function() {
console.log('timeout hit');
observer.onNext(42);
observer.onCompleted();
}, 1000);
console.log('started');
});
var sub = source.subscribe(function(x) {
console.log('next ' + x);
}, function(err) {
console.error(err);
}, function() {
console.info('done');
});
setTimeout(function() {
sub.dispose()
}, 500);
Ecco un output della console sto ottenendo.
Console was cleared
script.js:10 started
script.js:22 Uncaught TypeError: sub.dispose is not a function
script.js:5 timeout hit
script.js:6 Uncaught TypeError: observer.onNext is not a function
plunker: https://plnkr.co/edit/w1ZJL64b8rnA92PVuEDF?p=catalogue
Is rxjs 5 api è molto diverso da rxjs 2.5 e observer.onNext(42);
e sub.dispose()
non è supportato più a lungo?
https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#observer-interface-changes-also-subjects – Cody