# Class: Future

## vertx-js/future~ Future

#### new Future()

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

Source:
  - vertx-js/future.js, line 30

### Methods

#### cause() → {todo}

A Throwable describing failure. This will be null if the operation succeeded.

Source:
  - vertx-js/future.js, line 126

##### Returns:

the cause or null if the operation succeeded.

Type
  todo

#### 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

Source:
  - vertx-js/future.js, line 81

#### completer() → {function}

Source:
  - vertx-js/future.js, line 221

##### Returns:

- an handler completing this future
- Type
    function

#### compose(handler, next) → {Future}

Compose this future with a provided `next` future.

When this (the one on which `compose` is called) future succeeds, the `handler` will be called with the completed value, this handler should complete the next future.

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

When this future fails, the failure will be propagated to the `next` future and the `handler` will not be called.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler
`next` | Future | the next future

Source:
  - vertx-js/future.js, line 177

##### Returns:

the next future, used for chaining

Type
  Future

#### 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

Source:
  - vertx-js/future.js, line 96

#### failed() → {boolean}

Did it fail?

Source:
  - vertx-js/future.js, line 154

##### Returns:

true if it failed or false otherwise

Type
  boolean

#### isComplete() → {boolean}

Has the future completed?

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

Source:
  - vertx-js/future.js, line 44

##### 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:
  - vertx-js/future.js, line 202

##### Returns:

the mapped future

Type
  Future

#### result() → {Object}

The result of the operation. This will be null if the operation failed.

Source:
  - vertx-js/future.js, line 112

##### 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:
  - vertx-js/future.js, line 61

##### Returns:

a reference to this, so it can be used fluently

Type
  Future

#### succeeded() → {boolean}

Did it succeed?

Source:
  - vertx-js/future.js, line 140

##### Returns:

true if it succeded or false otherwise

Type
  boolean