Nexus API Reference

Future
in package

Read onlyYes
FinalYes
Tags
psalm-api

A handle to a pending async result.

Asks are eager - the request is sent at ask() call time. await() suspends the current fiber until the reply arrives or the timeout fires.

template

R of object

Table of Contents

Methods

__construct()  : mixed
all()  : Future<string|int, FutureResult<string|int, object>>
Wait for all futures and collect their results, keyed identically to the input.
await()  : R
Block the current fiber until the result is available.
cancel()  : void
failed()  : self
Create a Future that is already failed.
flatMap()  : Future<string|int, U>
Chain a dependent ask. Lazy - does not block.
isResolved()  : bool
map()  : Future<string|int, U>
Transform the result when it arrives. Lazy - does not block.
onCancel()  : self
Register a callback invoked when this future is cancelled.
resolved()  : self
Create a Future that is already completed with the given value.

Methods

all()

Wait for all futures and collect their results, keyed identically to the input.

public static all(array<string|int, Future<string|int, object>> $futures) : Future<string|int, FutureResult<string|int, object>>

If any future fails, the combined future fails with the first failure encountered.

Parameters
$futures : array<string|int, Future<string|int, object>>
Return values
Future<string|int, FutureResult<string|int, object>>

await()

Block the current fiber until the result is available.

public await() : R
Tags
throws
FutureException
Return values
R

cancel()

public cancel() : void

flatMap()

Chain a dependent ask. Lazy - does not block.

public flatMap(callable(R): Future<string|int, U$fn) : Future<string|int, U>
Parameters
$fn : callable(R): Future<string|int, U>
Tags
template

U of object

Return values
Future<string|int, U>

isResolved()

public isResolved() : bool
Return values
bool

map()

Transform the result when it arrives. Lazy - does not block.

public map(callable(R): U $fn) : Future<string|int, U>
Parameters
$fn : callable(R): U
Tags
template

U of object

Return values
Future<string|int, U>

onCancel()

Register a callback invoked when this future is cancelled.

public onCancel(callable(): void $callback) : self
Parameters
$callback : callable(): void
Return values
self

resolved()

Create a Future that is already completed with the given value.

public static resolved(R2 $value) : self
Parameters
$value : R2
Tags
template

R2 of object

Return values
self

        
On this page

Search results