GObject.Object.prototype.watch_closure

function watch_closure(closure: Function): void {
    // Gjs wrapper for g_object_watch_closure()
}
  

This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling GObject.Closure.invalidate on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, GObject.Object.ref and GObject.Object.unref are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

closure

GClosure to watch