Promise

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

The @see \io\vertx\jphp\core\Promise::future method returns the @see \io\vertx\jphp\core\Future associated with a promise, the future can be used for getting notified of the promise completion and retrieve its value.

A promise extends Handler> so it can be used as a callback.

package

Default

Methods

__construct

__construct() 

Calls <code>complete(null)</code>

complete( $arg0 = null) : void

complete()

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

Any handler set on the associated promise will be called.

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

Arguments

$arg0

mixed

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)

Calls @see \io\vertx\jphp\core\Promise::fail with the message.

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

Arguments

$arg0

string | \Exception

Create a failed promise with the specified failure <code>cause</code>.

failedPromise( $arg0) : \io\vertx\jphp\core\Promise<T>
static

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

Create a failed promise with the specified failureMessage.

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

Arguments

$arg0

string | \Exception

Response

\io\vertx\jphp\core\Promise

the promise

future

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

Response

\io\vertx\jphp\core\Future

the {@link Future} associated with this promise, it can be used to be aware of the promise completion

Create a promise that hasn't completed yet

promise() : \io\vertx\jphp\core\Promise<T>
static

Response

\io\vertx\jphp\core\Promise

the promise

Create a succeeded promise with a <code>null</code> result

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

succeededPromise()

Created a succeeded promise with the specified result.

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

Arguments

$arg0

mixed

Response

\io\vertx\jphp\core\Promise

the promise

Calls <code>tryComplete(null)</code>.

tryComplete( $arg0 = null) : boolean

tryComplete()

Like @see \io\vertx\jphp\core\Promise::complete but returns false when the promise is already completed instead of throwing an \java.lang.IllegalStateException, it returns true otherwise.

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

Arguments

$arg0

mixed

Response

boolean

{@code false} when the future is already completed

Like @see \io\vertx\jphp\core\Promise::fail but returns <code>false</code> when the promise is already completed instead of throwing an {@link java.lang.IllegalStateException}, it returns <code>true</code> otherwise.

tryFail( $arg0) : boolean

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

Calls @see \io\vertx\jphp\core\Promise::fail with the message.

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

Arguments

$arg0

string | \Exception

Response

boolean

{@code false} when the future is already completed