Skip to content

API Reference / @gtkx/runtime / registerClass

Function: registerClass()

registerClass<T, TProperties, TSignals>(klass, options?): RegisteredClass<T, TProperties, TSignals>

Defined in: packages/runtime/dist/register-class.d.ts:104

Registers a wrapper subclass as a GType with discovered vfuncs, properties, signals, and interfaces. Vfuncs must be prototype methods; function-valued fields never reach the vtable. A matching on<SignalName> method becomes the signal's default handler.

vfuncConstructed runs before field initializers and the constructor body. Native-created instances never run the JavaScript constructor, so native-required state belongs in properties or vfuncConstructed. A new Gio.AsyncInitable must implement vfuncInitAsync.

Type Parameters

T

T extends AnyClass

TProperties

TProperties extends Record<string, object> = Record<never, object>

TSignals

TSignals extends Record<string, SignalSpec> = Record<never, SignalSpec>

Parameters

klass

T

The wrapper subclass to register.

options?

RegisterClassOptions<T["prototype"], TProperties, TSignals>

Additional GType configuration.

Returns

RegisteredClass<T, TProperties, TSignals>

The registered class with declared properties and signals in its type.

Throws

For invalid parents, names, interfaces, vfuncs, properties, signals, or widget options. A classInit exception propagates after the static type has been registered and cannot be undone.

Released under the MPL-2.0 License.