Skip to content

API Reference / @gtkx/runtime / promisify

Function: promisify() ​

promisify<R, T>(asyncFn, finish, cancellable, ...leading): Promise<T>

Defined in: packages/runtime/src/promisify.ts:76

Wraps a GIO-style asynchronous function that takes a completion callback into a promise, invoking the finish function to extract the result. Outside production, the call site's stack is captured and attached as the rejection error's cause.

Type Parameters ​

R ​

R extends object

T ​

T

Parameters ​

asyncFn ​

(...args) => void

The async function, called with the leading arguments, the cancellable, and a completion callback.

finish ​

FinishResult<R, T>

Extracts the result from the async result passed to the completion callback.

cancellable ​

object | null | undefined

A cancellable object, or null/undefined for none.

leading ​

...unknown[]

Arguments passed to asyncFn before the cancellable and callback.

Returns ​

Promise<T>

A promise resolving to the finished result, or rejecting if finish throws.