私はこのチュートリアルhttps://egghead.io/lessons/rxjs-creating-an-observableを使用していますが、これは2.5.2 rxjsバージョンを参照しています。最新のrxjsを参照するときにrxjsエラーが発生する
私は、最新のrx.umd.js
[email protected]"
からNPMパッケージ<script src="node_modules/rxjs/bundles/rx.umd.js"></script>
を参照すると、ここで私が実行しようとしていますコードでいます:ここで
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);
は、私が取得していますコンソール出力です。
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
がrxjs 5 APIでrxjs 2.5とobserver.onNext(42);
とsub.dispose()
大きく異なるのは、サポート長くはないのですか?
https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#observer-interface-changes-also-subjects – Cody