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 (50), 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

Dex.Promise is a convenient Dex.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:

Dex.Promise

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

classmethod new_cancellable()
Returns:

a Dex.Promise

Return type:

Dex.Promise

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 or None

Return type:

Gio.Cancellable or None

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(), then None is returned.

reject(error)
Parameters:

error (GLib.Error) – a GLib.Error

Marks the promise as rejected, indicating a failure.

resolve(value)
Parameters:

value (GObject.Value) – a GObject.Value containing the resolved value

Sets the result for a 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 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 GLib.Variant

If variant is floating, its reference is consumed.

New in version 0.8.