Future

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

package

Default

Methods

__construct

__construct() 

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

cause() : \Exception

Response

\Exception

the cause or null if the operation succeeded.

Set a null result. Any handler will be called, if there is one, and the future will be marked as completed.

complete( $arg0 = null) : void

complete()

Set the result. Any handler will be called, if there is one, and the future will be marked as completed.

param $result [mixed] the result complete($result)

Arguments

$arg0

mixed

completer

completer() : callable

Response

callable

an handler completing this future

Compose this future with a <code>mapper</code> function.<p>

compose( $arg0,  $arg1 = null) : \io\vertx\jphp\core\Future<U>

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.

param $mapper [callable] the mapper function compose($mapper)

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.

param $handler [callable] the handler param $next [Future] the next future compose($handler, $next)

Arguments

$arg0

callable

$arg1

Future

Response

\io\vertx\jphp\core\Future

the composed future

Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.

fail( $arg0) : void

param $cause [\Exception] the failure cause fail($cause)

Try to set the failure. When it happens, any handler will be called, if there is one, and the future will be marked as completed.

param $failureMessage [string] the failure message fail($failureMessage)

Arguments

$arg0

string | \Exception

Did it fail?

failed() : boolean

Response

boolean

true if it failed or false otherwise

Create a failed future with the specified failure cause.

failedFuture( $arg0) : \io\vertx\jphp\core\Future<T>
static

param $t [\Exception] the failure cause as a Throwable failedFuture($t)

Create a failed future with the specified failure message.

param $failureMessage [string] the failure message failedFuture($failureMessage)

Arguments

$arg0

string | \Exception

Response

\io\vertx\jphp\core\Future

the future

Create a future that hasn't completed yet

future( $arg0 = null) : \io\vertx\jphp\core\Future<T>
static

future()

Create a future that hasn't completed yet and that is passed to the handler before it is returned.

param $handler [callable] the handler future($handler)

Arguments

$arg0

callable

Response

\io\vertx\jphp\core\Future

the future

Has the future completed? <p> It's completed if it's either succeeded or failed.

isComplete() : boolean

Response

boolean

true if completed, false if not

Apply a <code>mapper</code> function on this future.<p>

map( $arg0) : \io\vertx\jphp\core\Future<U>

When this future succeeds, the mapper will be called with the completed value and this mapper returns a value. This value 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.

param $mapper [callable] the mapper function map($mapper)

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.

param $value [mixed] the value that eventually completes the mapped future map($value)

Arguments

$arg0

callable | mixed

Response

\io\vertx\jphp\core\Future

the mapped future

Map the result of a future to <code>null</code>.<p>

mapEmpty() : \io\vertx\jphp\core\Future<V>

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.

Response

\io\vertx\jphp\core\Future

the mapped future

Apply a <code>mapper</code> function on this future.<p>

otherwise( $arg0) : \io\vertx\jphp\core\Future<T>

When this future fails, the mapper will be called with the completed value and this mapper returns a value. This value 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 succeeds, the result will be propagated to the returned future and the mapper will not be called.

param $mapper [callable] the mapper function otherwise($mapper)

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.

param $value [mixed] the value that eventually completes the mapped future otherwise($value)

Arguments

$arg0

callable | mixed

Response

\io\vertx\jphp\core\Future

the mapped future

Map the failure of a future to <code>null</code>.<p>

otherwiseEmpty() : \io\vertx\jphp\core\Future<T>

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.

Response

\io\vertx\jphp\core\Future

the mapped future

Handles a failure of this Future by returning the result of another Future.

recover( $arg0) : \io\vertx\jphp\core\Future<T>

If the mapper fails, then the returned future will be failed with this failure.

Arguments

$arg0

callable

Response

\io\vertx\jphp\core\Future

A recovered future

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

result() : mixed

Response

mixed

the result or null if the operation failed.

Set a handler for the result.

setHandler( $arg0) : $this

If the future has already been completed it will be called immediately. Otherwise it will be called when the future is completed.

Arguments

$arg0

callable

Response

$this

a reference to this, so it can be used fluently

Did it succeed?

succeeded() : boolean

Response

boolean

true if it succeded or false otherwise

Create a succeeded future with a null result

succeededFuture( $arg0 = null) : \io\vertx\jphp\core\Future<T>
static

succeededFuture()

Created a succeeded future with the specified result.

param $result [mixed] the result succeededFuture($result)

Arguments

$arg0

mixed

Response

\io\vertx\jphp\core\Future

the future

Try to set the result. When it happens, any handler will be called, if there is one, and the future will be marked as completed.

tryComplete( $arg0 = null) : boolean

tryComplete()

Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.

param $result [mixed] the result tryComplete($result)

Arguments

$arg0

mixed

Response

boolean

false when the future is already completed

Try to set the failure. When it happens, any handler will be called, if there is one, and the future will be marked as completed.

tryFail( $arg0) : boolean

param $cause [\Exception] the failure cause tryFail($cause)

Try to set the failure. When it happens, any handler will be called, if there is one, and the future will be marked as completed.

param $failureMessage [string] the failure message tryFail($failureMessage)

Arguments

$arg0

string | \Exception

Response

boolean

false when the future is already completed