Wait for the promise to resolve or reject, if resolved the callback function will be called with it's value and if rejected the rejectFn will be called with the reason. If the passed promise argument is not a promise the callback will be called synchronously with the value.
The value or promise like value to wait for
The callback to call on the promise successful resolving.
Optional
rejectFn: ((reason: any) => TResult2 | IPromise<TResult2> | PromiseLike<TResult2>)The callback to call when the promise rejects
Optional
finallyFn: (() => void)The callback to call once the promise has resolved or rejected
The passed value, if it is a promise and there is either a resolve or reject handler then it will return a chained promise with the value from the resolve or reject handler (depending whether it resolve or rejects)
let promise = createPromise<number>((resolve, reject) => {
resolve(42);
});
// Handle via a chained promise
let chainedPromise = promise.then((value) => {
// Do something with the value
});
// Handle via doAwait
doAwait(promise, (value) => {
// Do something with the value
});
// It can also handle the raw value, so you could process the result of either a
// synchrounous return of the value or a Promise
doAwait(42, (value) => {
// Do something with the value
});
Wait for the promise to resolve or reject, if resolved the callback function will be called with it's value and if rejected the rejectFn will be called with the reason. If the passed promise argument is not a promise the callback will be called synchronously with the value.
The value or promise like value to wait for
The callback to call on the promise successful resolving.
Optional
rejectFn: ((reason: any) => TResult2 | IPromise<TResult2> | PromiseLike<TResult2>)The callback to call when the promise rejects
Optional
finallyFn: (() => void)The callback to call once the promise has resolved or rejected
The passed value, if it is a promise and there is either a resolve or reject handler then it will return a chained promise with the value from the resolve or reject handler (depending whether it resolve or rejects)
let promise = createPromise<number>((resolve, reject) => {
resolve(42);
});
// Handle via a chained promise
let chainedPromise = promise.then((value) => {
// Do something with the value
});
// Handle via doAwait
doAwait(promise, (value) => {
// Do something with the value
});
// It can also handle the raw value, so you could process the result of either a
// synchrounous return of the value or a Promise
doAwait(42, (value) => {
// Do something with the value
});
Wait for the promise to resolve or reject, if resolved the callback function will be called with it's value and if rejected the rejectFn will be called with the reason. If the passed promise argument is not a promise the callback will be called synchronously with the value.
Param: value
The value or promise like value to wait for
Param: resolveFn
The callback to call on the promise successful resolving.
Param: rejectFn
The callback to call when the promise rejects
Param: finallyFn
The callback to call once the promise has resolved or rejected
Returns
The passed value, if it is a promise and there is either a resolve or reject handler then it will return a chained promise with the value from the resolve or reject handler (depending whether it resolve or rejects)
Example