NAME

Promise::XS::Deferred

SYNOPSIS

See Promise::XS.

DESCRIPTION

This class implements a promise’s “producer” behavior. It is not to be instantiated directly, but rather via Promise::XS.

BASIC METHODS

The following are what’s needed to implement normal promise workflows:

$obj = OBJ->resolve( @ARGUMENTS )

Resolves OBJ’s promise, assigning the given @ARGUMENTS as the value. Returns OBJ.

IMPORTANT: Behavior here is not defined if anything in @ARGUMENTS is itself a promise.

$obj = OBJ->reject( @ARGUMENTS )

Like resolve() but rejects the promise instead.

ADDITIONAL METHODS

$yn = OBJ->is_pending()

Returns a boolean that indicates whether the promise is still pending (as opposed to resolved or rejected).

This shouldn’t normally be necessary but can be useful in debugging.

For compatibility with preexisting promise libraries, is_in_progress() exists as an alias for this logic.

$obj = OBJ->clear_unhandled_rejection()

Ordinarily, if a promise’s rejection is “unhandled”, a warning about the unhandled rejection is produced. Call this after reject() to silence that warning. (It’s generally better, of course, to handle all errors.)