次の仕様で新しい JSBIN プロジェクトを実行すると:
- タブの利用: JavaScript、コンソール
- ライブラリの追加: RxJS 5.0.0
次に、JavaScript 領域で次のコード ブロックを実行します。
var observable = Rx.Observable.create(observer => {
setInterval(() => {
observer.onNext('This is the output of my async operation');
}, 2000);
});
observable.subscribe(response => console.log(response));
上記のコードは、コンソール領域に次の出力をレンダリングする必要があります。
"This is the output of my async operation"
2 秒後、コンソール領域がレンダリングされます。
"This is the output of my async operation"
ただし、次のエラーが表示されます。
"error"
-----------------------------
"ReferenceError: Rx is not defined
at yivicazake.js:3:4
at https://static.jsbin.com/js/prod/runner-3.39.12.min.js:1:13926
at https://static.jsbin.com/js/prod/runner-3.39.12.min.js:1:10855
JSBINを使用してRxJSをライブラリとしてプルするのはこれが初めてで、誰かがこの特定のエラーを経験したことを願っています。