Class Promise
Similar to a Signal, except it only allows a value to be resolved once.
Encapsulates an unresolved value and a promise to resolve it later. Use it to
simplify communication between asyncronous processes.
-
Alchemy\util\promise\Waitable
-
Alchemy\util\promise\Signal
-
Alchemy\util\promise\Promise
Methods summary
public static
Alchemy\util\promise\Promise
|
#
when( array $promises = array() )
Return a single promise that is resolved when the given array of promise are
all resolved.
Return a single promise that is resolved when the given array of promise are
all resolved.
Parameters
Returns
|
public
|
|
public
|
#
__call( mixed $name, mixed $args )
If possible, return a Promise to call the method later, else just call the
method.
If possible, return a Promise to call the method later, else just call the
method.
|
public
|
#
__tostring( )
Wait for the Promise to resolve and cast it to a string.
Wait for the Promise to resolve and cast it to a string.
|
public static
string|null
|
#
get_return_type( string $cls, string $method )
Get the return type of a given method on an IPromisable class, if known.
Get the return type of a given method on an IPromisable class, if known.
Parameters
- $cls
string $cls class name
- $method
string $method method name
Returns
string|null return type
|
protected
|
#
precheck( )
Subclasses override this to do something during check()
Subclasses override this to do something during check()
Overrides
|
public
this
|
#
resolve( mixed $result )
A Promise will only resolve once. Further resolve()s will be ignored.
A Promise will only resolve once. Further resolve()s will be ignored.
Parameters
Returns
this
Overrides
|
public
|
#
then( mixed $fnThen = null, mixed $fnFail = null, mixed $type = null, mixed $check = true )
Returns a Promise of a callback on the results of this Promise. If that in
turn returns a Promise, it will wait on that Promise as well. Use this to chain
asyncronous callbacks.
Returns a Promise of a callback on the results of this Promise. If that in
turn returns a Promise, it will wait on that Promise as well. Use this to chain
asyncronous callbacks.
|