Class: Future

vertx-js/future~ Future

new Future()

Represents the result of an action that may, or may not, have occurred yet.

Source:

Methods

cause() → {todo}

A Throwable describing failure. This will be null if the operation succeeded.
Source:
Returns:
the cause or null if the operation succeeded.
Type
todo

compose(mapper) → {Future}

Compose this future with a mapper function.

When this future (the one on which compose is called) succeeds, the mapper will be called with the completed value and this mapper returns another future object. This returned future completion will complete the future returned by this method call.

If the mapper throws an exception, the returned future will be failed with this exception.

When this future fails, the failure will be propagated to the returned future and the mapper will not be called.

Parameters:
Name Type Description
mapper function the mapper function
Source:
Returns:
the composed future
Type
Future

failed() → {boolean}

Did it fail?
Source:
Returns:
true if it failed or false otherwise
Type
boolean

getHandler() → {function}

Source:
Returns:
the handler for the result
Type
function

isComplete() → {boolean}

Has the future completed?

It's completed if it's either succeeded or failed.

Source:
Returns:
true if completed, false if not
Type
boolean

map(value) → {Future}

Map the result of a future to a specific value.

When this future succeeds, this value will complete the future returned by this method call.

When this future fails, the failure will be propagated to the returned future.

Parameters:
Name Type Description
value Object the value that eventually completes the mapped future
Source:
Returns:
the mapped future
Type
Future

mapEmpty() → {Future}

Map the result of a future to null.

This is a conveniency for future.map((T) null) or future.map((Void) null).

When this future succeeds, null will complete the future returned by this method call.

When this future fails, the failure will be propagated to the returned future.

Source:
Returns:
the mapped future
Type
Future

otherwise(value) → {Future}

Map the failure of a future to a specific value.

When this future fails, this value will complete the future returned by this method call.

When this future succeeds, the result will be propagated to the returned future.

Parameters:
Name Type Description
value Object the value that eventually completes the mapped future
Source:
Returns:
the mapped future
Type
Future

otherwiseEmpty() → {Future}

Map the failure of a future to null.

This is a convenience for future.otherwise((T) null).

When this future fails, the null value will complete the future returned by this method call.

When this future succeeds, the result will be propagated to the returned future.

Source:
Returns:
the mapped future
Type
Future

recover(mapper) → {Future}

Handles a failure of this Future by returning the result of another Future. If the mapper fails, then the returned future will be failed with this failure.
Parameters:
Name Type Description
mapper function A function which takes the exception of a failure and returns a new future.
Source:
Returns:
A recovered future
Type
Future

result() → {Object}

The result of the operation. This will be null if the operation failed.
Source:
Returns:
the result or null if the operation failed.
Type
Object

setHandler(handler) → {Future}

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
Source:
Returns:
a reference to this, so it can be used fluently
Type
Future

succeeded() → {boolean}

Did it succeed?
Source:
Returns:
true if it succeded or false otherwise
Type
boolean