This does seem to be an omission in GJS. We should probably have an override for it. Could you please open a feature request issue on GNOME / gjs · GitLab?
You might be able to retrieve the handler ID with GObject.signal_handler_find()
although it looks like searching by function doesn’t work in GJS, so you could only use it if you were certain there would be no other signal handlers connected to that signal, e.g. on an internal object:
gjs> const {GObject} = imports.gi;
gjs> const o = new GObject.Object()
gjs> function foo() {}
gjs> o.connect('notify', foo)
14
gjs> function bar() {}
gjs> o.connect('notify', bar)
15
gjs> GObject.signal_handler_find(o, GObject.SignalMatchType.ID, GObject.signal_lookup('notify', GObject.Object), 0, foo, null, null)
14
gjs> GObject.signal_handler_find(o, GObject.SignalMatchType.ID, GObject.signal_lookup('notify', GObject.Object), 0, bar, null, null)
14
gjs> GObject.signal_handler_find(o, GObject.SignalMatchType.ID | GObject.SignalMatchType.CLOSURE, GObject.signal_lookup('notify', GObject.Object), 0, foo, null, null)
0
gjs> GObject.signal_handler_find(o, GObject.SignalMatchType.ID | GObject.SignalMatchType.CLOSURE, GObject.signal_lookup('notify', GObject.Object), 0, bar, null, null)
0
gjs> GObject.signal_handler_find(o, GObject.SignalMatchType.ID | GObject.SignalMatchType.FUNC, GObject.signal_lookup('notify', GObject.Object), 0, null, foo, null)
0
gjs> GObject.signal_handler_find(o, GObject.SignalMatchType.ID | GObject.SignalMatchType.FUNC, GObject.signal_lookup('notify', GObject.Object), 0, null, bar, null)
0