GObject.Object.prototype.notify_by_pspec

function notify_by_pspec(pspec: GObject.ParamSpec): void {
    // Gjs wrapper for g_object_notify_by_pspec()
}
  

Emits a "notify" signal for the property specified by pspec on object.

This function omits the property name lookup, hence it is faster than GObject.Object.prototype.notify.

One way to avoid using GObject.Object.prototype.notify from within the class that registered the properties, and using GObject.Object.prototype.notify_by_pspec instead, is to store the GParamSpec used with GObject.ObjectClass.install_property inside a static array, e.g.:

|[<!-- language="C" --> enum { PROP_0, PROP_FOO, PROP_LAST };

static GParamSpec *properties[PROP_LAST];

static void my_object_class_init (MyObjectClass *klass) { properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo", 0, 100, 50, G_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_FOO, properties[PROP_FOO]); } ]|

and then notify a change on the "foo" property with:

|[<!-- language="C" --> g_object_notify_by_pspec (self, properties[PROP_FOO]); ]|

Since 2.26

pspec

the GObject.ParamSpec of a property installed on the class of object.