GObject.Object.prototype.connect

function connect(signal_name: String, handler: Function): Number(gint) {
    // Gjs wrapper for g_signal_connect()
}
  

Connects handler to signal_name on the object on which this method is invoked, and returns an integer ID different than 0 that can be passed to GObject.Object.prototype.disconnect

handler must have the proper signature for signal_name, as described in the individual signal documentations, although this is not checked until the signal is first emitted.

When the signal is emitted by the object implementation, handler will be invoked, with a null this object and the emitting object as the first argument always.

signal_name

the signal to connect to

handler

the function handling the signal

Returns

the signal connection ID