Overview

Namespaces

  • Alchemy
    • core
      • query
      • schema
    • dialect
    • engine
    • orm
    • tests
    • util
      • promise
  • PHP

Classes

  • Promise
  • Signal
  • SignalFn_Then
  • Waitable

Interfaces

  • IPromisable

Exceptions

  • SerializableException
  • TimeoutException
  • TypeException
  • Overview
  • Namespace
  • Class
  • Tree

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
Extended by Alchemy\util\promise\Signal
Extended by Alchemy\util\promise\Promise
Namespace: Alchemy\util\promise
Located at alchemy/util/promise/Promise.php
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

$promises
array
$promises

Returns

Alchemy\util\promise\Promise
public
# __get( mixed $name )
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

Alchemy\util\promise\Signal::precheck()
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

$result
mixed
$result

Returns

this

Overrides

Alchemy\util\promise\Waitable::resolve()
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.

Methods inherited from Alchemy\util\promise\Signal
__construct()
Methods inherited from Alchemy\util\promise\Waitable
__invoke(), check(), expect(), timeout(), type(), wait()
Properties summary
protected array $onResolvePromises array()
#
Properties inherited from Alchemy\util\promise\Signal
$fnSource
Properties inherited from Alchemy\util\promise\Waitable
$result, $spin, $started, $timeout
API documentation generated by ApiGen 2.8.0