Skip to content

API Reference / @gtkx/react / index / useSignal

Function: useSignal() ​

useSignal<T, S>(object, signal, handler, options?): void

Defined in: packages/react/src/hooks/use-signal.ts:24

Connects a handler to a GObject signal for the lifetime of the component, reconnecting when the object changes.

Each emission runs the handler from the latest committed render, so it does not have to be stable and a changing handler never reconnects the signal.

Type Parameters ​

T ​

T extends Pick<Object, "__signals__" | "__type__">

S ​

S extends string

Parameters ​

object ​

T | null | undefined

signal ​

S

The signal name, optionally with a ::detail suffix.

handler ​

SignalMap<T>[S]

options? ​

UseSignalOptions = {}

isAfter runs the handler after the default handler; isImmediate also invokes it on connect.

Returns ​

void