GLib.io_add_watch

function io_add_watch(channel: GLib.IOChannel, priority: Number(gint), condition: GLib.IOCondition, func: GLib.IOFunc): Number(guint) {
    // Gjs wrapper for g_io_add_watch_full()
}
  

Adds the GLib.IOChannel into the default main loop context with the given priority.

This internally creates a main loop source using GLib.io_create_watch and attaches it to the main loop context with GLib.Source.prototype.attach. You can do these steps manually if you need greater control.

channel

a GLib.IOChannel

priority

the priority of the GLib.IOChannel source

condition

the condition to watch for

func

the function to call when the condition is satisfied

Returns

the event source id