Sonu Kapoor def4127bf1 fix(docs-infra): convert hard-coded comparing-observables examples into a proper mini-app (#34327)
Previously, the examples in the `comparing-observables` guide were hard-coded.
This made it impossible to test them and verify they are correct.

This commit fixes this by converting them into a proper mini-app. In a
subsequent commit, tests will be added to verify that the source code
works as expected (and guard against regressions).

Fixes #31024

PR Close #34327
2020-01-21 13:14:46 -05:00

26 lines
376 B
TypeScript

// #docregion promise
// initiate execution
const promise = new Promise<number>((resolve, reject) => {
// Executer fn...
});
promise.then(value => {
// handle result here
});
// #enddocregion promise
// #docregion chain
promise.then(v => 2 * v);
// #enddocregion chain
// #docregion error
promise.then(() => {
throw Error('my error');
});
// #enddocregion error