Dex.Promise¶
- Subclasses:
None
Methods¶
- Inherited:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
None
Fields¶
None
Class Details¶
- class Dex.Promise¶
- Bases:
- Abstract:
No
Dex.Promise
is a convenientDex.Future
for prpoagating a result or rejection in appliction and library code.Use this when there is not a more specialized
Dex.Future
for your needs to propagate a result or rejection to the caller in an asynchronous fashion.- classmethod new()¶
- Return type:
- classmethod new_cancellable()¶
- Returns:
- Return type:
Creates a new
Dex.Promise
that can propagate cancellation if the promise is discarded.This can be used to plumb cancellation between promises and
Gio.AsyncReadyCallback
based APIs.
- get_cancellable()¶
- Returns:
a
Gio.Cancellable
orNone
- Return type:
Gets a
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
Gio.AsyncReadyCallback
based API.If self was created with
Dex.Promise.new
(), thenNone
is returned.
- reject(error)¶
- Parameters:
error (
GLib.Error
) – aGLib.Error
Marks the promise as rejected, indicating a failure.
- resolve(value)¶
- Parameters:
value (
GObject.Value
) – aGObject.Value
containing the resolved value
Sets the result for a
Dex.Promise
.
- resolve_boxed(boxed_type, instance)¶
- Parameters:
boxed_type (
GObject.GType
) – aGObject.GType
ofGObject.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.Object
orNone
) – aGObject.Object
- resolve_variant(variant)¶
- Parameters:
variant (
GLib.Variant
orNone
) – aGLib.Variant
If variant is floating, its reference is consumed.
New in version 0.8.