Skip to content

Commit

Permalink
signals.js: add signalHandlerIsConnected method
Browse files Browse the repository at this point in the history
  • Loading branch information
dalcde authored and mtwebster committed Apr 23, 2017
1 parent 5dcc3c8 commit a029c27
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions modules/signals.js
Expand Up @@ -76,6 +76,22 @@ function _disconnect(id) {
throw new Error("No signal connection " + id + " found");
}

function _signalHandlerIsConnected(id) {
if (! '_signalConnections' in this)
return false;

for (let connection of this._signalConnections) {
if (connection.id == id) {
if (connection.disconnected)
return false;
else
return true;
}
}

return false;
}

function _disconnectAll() {
if ('_signalConnections' in this) {
while (this._signalConnections.length > 0) {
Expand Down Expand Up @@ -152,6 +168,7 @@ function addSignalMethods(proto) {
_addSignalMethod(proto, "connect", _connect);
_addSignalMethod(proto, "disconnect", _disconnect);
_addSignalMethod(proto, "emit", _emit);
_addSignalMethod(proto, "signalHandlerIsConnected", _signalHandlerIsConnected)
// this one is not in GObject, but useful
_addSignalMethod(proto, "disconnectAll", _disconnectAll);
}
Expand Down

0 comments on commit a029c27

Please sign in to comment.