-
-
Save laszlokiraly/15a030c8ae27336b2f382b4be046b554 to your computer and use it in GitHub Desktop.
Observable/Observer Error Handling JS Bin// source https://jsbin.com/kujobeciqu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.js"></script> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| var observable = Rx.Observable.create(function(obs){ | |
| obs.next(42); | |
| obs.error(new Error('badam')); // observer can handle it | |
| throw new Error('badam tss'); // escalates quickly | |
| }); | |
| var observer = observable.subscribe(function onValue(val){ | |
| console.log(val); | |
| }, function onError(err) { | |
| console.log(err + ' ts'); | |
| }); | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">var observable = Rx.Observable.create(function(obs){ | |
| obs.next(42); | |
| obs.error(new Error('badam')); // observer can handle it | |
| throw new Error('badam tss'); // escalates quickly | |
| }); | |
| var observer = observable.subscribe(function onValue(val){ | |
| console.log(val); | |
| }, function onError(err) { | |
| console.log(err + ' ts'); | |
| });</script></body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var observable = Rx.Observable.create(function(obs){ | |
| obs.next(42); | |
| obs.error(new Error('badam')); // observer can handle it | |
| throw new Error('badam tss'); // escalates quickly | |
| }); | |
| var observer = observable.subscribe(function onValue(val){ | |
| console.log(val); | |
| }, function onError(err) { | |
| console.log(err + ' ts'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment