@serenity-is/corelib / nowOrThen
Function: nowOrThen()
nowOrThen<
T,TResult>(value,then):TResult|PromiseLike<TResult>
Defined in: src/base/system.ts:590
Runs a callback with a value at once when it is not a promise, or once it resolves when it is, so that the code after
a call that may or may not wait doesn't wait when it doesn't, which await would, as it always yields. E.g. a widget
that defers its initialization goes on after its base class's deferredInit(), so that init() still does the work
before the first wait: return nowOrThen(super.deferredInit(), () => this.initMyPart());.
Type Parameters
T
T
TResult
TResult
Parameters
value
The value, or a promise of it.
T | PromiseLike<T>
then
(value) => TResult | PromiseLike<TResult>
The callback.
Returns
TResult | PromiseLike<TResult>
What the callback returns, or a promise of it when the value is a promise.