Dex.Promise¶
- Subclasses:
None
Methods¶
- Inherited:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
None
Fields¶
None
Class Details¶
- class Dex.Promise¶
- Bases:
- Abstract:
No
DexPromiseis a convenient [class`Dex`.Future] for propagating a result or rejection in application and library code.Use this when there is not a more specialized
DexFuturefor your needs to propagate a result or rejection to the caller in an asynchronous fashion.- classmethod new()¶
- Return type:
Creates a new promise which may be completed or rejected using the available methods.
- classmethod new_cancellable()¶
- Returns:
a [class`Dex`.Promise]
- Return type:
Creates a new [class`Dex`.Promise] that can propagate cancellation if the promise is discarded.
This can be used to plumb cancellation between promises and [callback`Gio`.AsyncReadyCallback] based APIs.
- get_cancellable()¶
- Returns:
a [class`Gio`.Cancellable] or
None- Return type:
Gets a [class`Gio`.Cancellable] that will cancel when the promise has been discarded (and therefore result no longer necessary).
This is useful when manually implementing wrappers around various [callback`Gio`.AsyncReadyCallback] based API.
If self was created with [ctor`Dex`.Promise.new], then
Noneis returned.
- reject(error)¶
- Parameters:
error (
GLib.Error) – a [struct`GLib`.Error]
Marks the promise as rejected, indicating a failure.
- resolve(value)¶
- Parameters:
value (
GObject.Value) – a [struct`GObject`.Value] containing the resolved value
Sets the result for a [class`Dex`.Promise].
- resolve_boxed(boxed_type, instance)¶
- Parameters:
boxed_type (
GObject.GType) – aGTypeofGObject.TYPE_BOXED
New in version 0.10.
- resolve_fd(fd)¶
- Parameters:
fd (
int) – a file-descriptor for the resolve to resolve to
Resolves the promise to fd.
The file-descriptor may be dup()’d by this function and fd closed immediately.
Use
Dex.Future.await_fd() or similar to retrieve the resolved FD.
- resolve_object(object)¶
- Parameters:
object (
GObject.ObjectorNone) – a [class`GObject`.Object]
- resolve_variant(variant)¶
- Parameters:
variant (
GLib.VariantorNone) – a [struct`GLib`.Variant]
If variant is floating, its reference is consumed.
New in version 0.8.