Skip to content

API Reference / @gtkx/runtime / wrapHandle

Function: wrapHandle() ​

Call Signature ​

wrapHandle(handle, cls?): null

Defined in: packages/runtime/src/registry.ts:446

Wraps a native handle, returning null for a null or undefined handle.

Without cls, resolves the runtime GType's wrapper, composes interface mixins, and reuses an existing wrapper. An instance that already carries a handle is returned unchanged. With cls, creates a bare instance, using its registerWrapperClassResolver to select a subclass if registered.

Parameters ​

handle ​

null | undefined

Native handle to wrap.

cls? ​

AnyClass

Wrapper class, or omitted to resolve it from the runtime GType.

Returns ​

null

Call Signature ​

wrapHandle<T>(handle, cls): T

Defined in: packages/runtime/src/registry.ts:447

Wraps a native handle, returning null for a null or undefined handle.

Without cls, resolves the runtime GType's wrapper, composes interface mixins, and reuses an existing wrapper. An instance that already carries a handle is returned unchanged. With cls, creates a bare instance, using its registerWrapperClassResolver to select a subclass if registered.

Type Parameters ​

T ​

T extends object

Parameters ​

handle ​

ExternalObject<Handle>

Native handle to wrap.

cls ​

AnyClass<T>

Wrapper class, or omitted to resolve it from the runtime GType.

Returns ​

T

Call Signature ​

wrapHandle<T>(handle, cls): T | null

Defined in: packages/runtime/src/registry.ts:449

Wraps a native handle, returning null for a null or undefined handle.

Without cls, resolves the runtime GType's wrapper, composes interface mixins, and reuses an existing wrapper. An instance that already carries a handle is returned unchanged. With cls, creates a bare instance, using its registerWrapperClassResolver to select a subclass if registered.

Type Parameters ​

T ​

T extends object

Parameters ​

handle ​

ExternalObject<Handle> | null | undefined

Native handle to wrap.

cls ​

AnyClass<T>

Wrapper class, or omitted to resolve it from the runtime GType.

Returns ​

T | null

Call Signature ​

wrapHandle(handle, cls?): TypedClass

Defined in: packages/runtime/src/registry.ts:454

Wraps a native handle, returning null for a null or undefined handle.

Without cls, resolves the runtime GType's wrapper, composes interface mixins, and reuses an existing wrapper. An instance that already carries a handle is returned unchanged. With cls, creates a bare instance, using its registerWrapperClassResolver to select a subclass if registered.

Parameters ​

handle ​

ExternalObject<Handle>

Native handle to wrap.

cls? ​

AnyClass

Wrapper class, or omitted to resolve it from the runtime GType.

Returns ​

TypedClass

Call Signature ​

wrapHandle(handle, cls?): TypedClass | null

Defined in: packages/runtime/src/registry.ts:455

Wraps a native handle, returning null for a null or undefined handle.

Without cls, resolves the runtime GType's wrapper, composes interface mixins, and reuses an existing wrapper. An instance that already carries a handle is returned unchanged. With cls, creates a bare instance, using its registerWrapperClassResolver to select a subclass if registered.

Parameters ​

handle ​

ExternalObject<Handle> | null | undefined

Native handle to wrap.

cls? ​

AnyClass

Wrapper class, or omitted to resolve it from the runtime GType.

Returns ​

TypedClass | null