new Future()
Represents the result of an action that may, or may not, have occurred yet.
Methods
-
complete(result)
-
Set the result. Any handler will be called, if there is one, and the future will be marked as completed.
Parameters:
Name Type Description result
Object the result -
fail(failureMessage)
-
Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.
Parameters:
Name Type Description failureMessage
string the failure message -
isComplete() → {boolean}
-
Has the future completed?
It's completed if it's either succeeded or failed.
Returns:
true if completed, false if not- Type
- boolean
-
setHandler(handler)
-
Set a handler for the result.
If the future has already been completed it will be called immediately. Otherwise it will be called when the future is completed.
Parameters:
Name Type Description handler
function the Handler that will be called with the result