Gio.AsyncInitable.prototype.init_async

function init_async(io_priority: Number(gint), cancellable: Gio.Cancellable, callback: Gio.AsyncReadyCallback): void {
    // Gjs wrapper for g_async_initable_init_async()
}
  

Starts asynchronous initialization of the object implementing the interface. This must be done before any real use of the object after initial construction. If the object also implements Gio.Initable you can optionally call Gio.Initable.prototype.init instead.

When the initialization is finished, callback will be called. You can then call Gio.AsyncInitable.prototype.init_finish to get the result of the initialization.

Implementations may also support cancellation. If cancellable is not null, then initialization can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.cancelled will be returned. If cancellable is not null, and the object doesn't support cancellable initialization, the error Gio.IOErrorEnum.not_supported will be returned.

As with Gio.Initable, if the object is not initialized, or initialization returns with an error, then all operations on the object except GObject.Object.prototype.ref and GObject.Object.prototype.unref are considered to be invalid, and have undefined behaviour. They will often fail with g_critical() or g_warning(), but this must not be relied on.

Implementations of this method must be idempotent: i.e. multiple calls to this function with the same argument should return the same results. Only the first call initializes the object; further calls return the result of the first call. This is so that it's safe to implement the singleton pattern in the GObject constructor function.

For classes that also support the Gio.Initable interface, the default implementation of this method will run the Gio.Initable.prototype.init function in a thread, so if you want to support asynchronous initialization via threads, just implement the Gio.AsyncInitable interface without overriding any interface methods.

Since 2.22

io_priority

the [I/O priority][io-priority] of the operation

cancellable

optional Gio.Cancellable object, null to ignore.

callback

a Gio.AsyncReadyCallback to call when the request is satisfied