Created
December 14, 2021 08:50
-
-
Save buzztaiki/f5322e88808dc3b4b7039707745d4765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see https://gitlab.gnome.org/GNOME/gjs/blob/master/doc/Modules.md#signals | |
const Signals = imports.signals; | |
class MyJSClass { | |
testSignalEmission () { | |
this.emit("example-signal", "moo", 42); | |
} | |
} | |
Signals.addSignalMethods(MyJSClass.prototype); | |
const obj = new MyJSClass(); | |
const handlerId = obj.connect("example-signal", (_obj, a, b) => { | |
print("handler1", a, b); | |
}); | |
obj.connect("example-signal", (_obj, a, b) => { | |
print("handler2", a, b); | |
}); | |
obj.testSignalEmission(); | |
obj.disconnect(handlerId); | |
obj.testSignalEmission(); | |
obj.disconnectAll(); |
Author
buzztaiki
commented
Dec 14, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment