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
26 lines
376 B
TypeScript
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
|