PromiseBase::Then (open)
Schedule functions to run when this promise is resolved or rejected
Syntax
LOADLIB "wh::promise.whlib";
OBJECT FUNCTION Then(FUNCTION PTR then, FUNCTION PTR onerror)Parameters
FUNCTION PTR thenFunction to run when the promise is resolved. Allowed signatures:
- MACRO resolve()
- VARIANT FUNCTION resolve()
- MACRO resolve(VARIANT value)
- VARIANT FUNCTION resolve(VARIANT value)
If a parameter is present, it will be set to the value this promise was resolved with.
If a value is returned, the returned promise is resolved to that value, otherwise
the returned promise is resolved to
DEFAULT RECORD. If an exception is thrown, the returned exception is rejected with that exception
FUNCTION PTR onerrorFunction to run when the promise is resolved. Allowed signatures:
- MACRO reject()
- VARIANT FUNCTION reject()
- MACRO reject(OBJECT exception)
- VARIANT FUNCTION reject(OBJECT exception)
If a parameter is present, it will be set to the exception object this promise was rejected with.
If a value is returned, the returned promise is resolved to that value, otherwise the returned promise is
resolved to
DEFAULT RECORD. If an exception is thrown, the returned exception is rejected with that exception
Return value
OBJECTPromise that will be resolved by the returned value of the then/onerror functions. If the relevant function is not set, the returned promise copy the state of this promise.