API Reference / @gtkx/runtime / registerClass
Function: registerClass()
registerClass<
T,TProperties,TSignals,TInterfaces>(klass,options?):RegisteredClass<T,TProperties,Record<keyofTSignals&string,SignalSpec>,TInterfaces>
Defined in: packages/runtime/src/register-class.ts:531
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.
As in GJS, vfuncDispose runs only while the instance's JavaScript object is alive. A disposal that follows its garbage collection skips the override and runs the parent implementation.
A ParamSpec from the properties option exposes name, nick, blurb, flags, valueType and ownerType as fields, and its default through getDefaultValue(). To look a property up on a registered class, use its class-struct wrapper, as in GObject.ObjectClass.peek(TaggedScale).findProperty("tag").
Type Parameters
T
T extends AnyClass
TProperties
TProperties extends Record<string, object> = Record<never, object>
TSignals
TSignals extends Record<string, SignalSpec> = Record<never, SignalSpec>
TInterfaces
TInterfaces extends readonly Interface<T["prototype"], object>[] = readonly Interface<T["prototype"], object>[]
Parameters
klass
T
The wrapper subclass to register.
options?
RegisterClassOptions<T["prototype"], TProperties, TSignals, TInterfaces>
Additional GType configuration.
Returns
RegisteredClass<T, TProperties, Record<keyof TSignals & string, SignalSpec>, TInterfaces>
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.