Do D's std.signals check for already-connected slot and simply ignore the call?
Enjoys Math
enjoysmath at gmail.com
Wed Oct 17 01:04:50 UTC 2018
If they don't, I have to wrap it like so:
import std.signals;
class Signal(T) {
protected:
mixin Signal!(T);
};
class Changed(T) : Signal!T {
protected:
void delegate(T)[] slots;
public:
override void connect(void delegate(T) slot) {
foreach (s; slots) {
if (s == slot)
return;
}
slots ~= slot;
super.connect(slot);
}
override void disconnect(void delegate(T) slot) {
import std.algorithm;
foreach (s; slots) {
if (s == slot) {
slots.remove(s);
super.disconnect(slot);
break;
}
}
}
override void disconnectAll() {
super.disconnectAll();
}
}
??
More information about the Digitalmars-d-learn
mailing list