Dex.Promise

g Dex.Future Dex.Future Dex.Promise Dex.Promise Dex.Future->Dex.Promise Dex.Object Dex.Object Dex.Object->Dex.Future

Subclasses:

None

Methods

Inherited:

Dex.Future (51), Dex.Object (2)

class

new ()

class

new_cancellable ()

get_cancellable ()

reject (error)

resolve (value)

resolve_boolean (value)

resolve_boxed (boxed_type, instance)

resolve_double (value)

resolve_fd (fd)

resolve_float (value)

resolve_int (value)

resolve_int64 (value)

resolve_long (value)

resolve_object (object)

resolve_string (value)

resolve_uint (value)

resolve_uint64 (value)

resolve_ulong (value)

resolve_variant (variant)

Virtual Methods

None

Fields

None

Class Details

class Dex.Promise
Bases:

Dex.Future

Abstract:

No

DexPromise is 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 DexFuture for your needs to propagate a result or rejection to the caller in an asynchronous fashion.

classmethod new()
Return type:

Dex.Promise

Creates a new promise which may be completed or rejected using the available methods.

classmethod new_cancellable()
Returns:

a [class`Dex`.Promise]

Return type:

Dex.Promise

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:

Gio.Cancellable or None

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 None is 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_boolean(value)
Parameters:

value (bool) –

Resolve promise to value.

resolve_boxed(boxed_type, instance)
Parameters:

New in version 0.10.

resolve_double(value)
Parameters:

value (float) –

Resolve promise to value.

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_float(value)
Parameters:

value (float) –

Resolve promise to value.

resolve_int(value)
Parameters:

value (int) –

Resolve promise to value.

resolve_int64(value)
Parameters:

value (int) –

Resolve promise to value.

resolve_long(value)
Parameters:

value (int) –

Resolve promise to value.

resolve_object(object)
Parameters:

object (GObject.Object or None) – a [class`GObject`.Object]

resolve_string(value)
Parameters:

value (str) – a string to use to resolve the promise

resolve_uint(value)
Parameters:

value (int) –

Resolve promise to value.

resolve_uint64(value)
Parameters:

value (int) –

Resolve promise to value.

resolve_ulong(value)
Parameters:

value (int) –

Resolve promise to value.

resolve_variant(variant)
Parameters:

variant (GLib.Variant or None) – a [struct`GLib`.Variant]

If variant is floating, its reference is consumed.

New in version 0.8.