SignalConnection

Represents a single connection between a signal and a slot.

This type is reference counted. When the reference count drops to zero, the connection will be detached automatically.

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Functions

disconnect
void disconnect()
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

connected
bool connected [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

Signal!() sig;
SignalConnection conn;
size_t cnt = 0;

void slot() { cnt++; }

// disconnecting using a disconnect() call
sig.socket.connect(conn, &slot);
sig.emit();
assert(cnt == 1);
conn.disconnect();
assert(!conn.connected);
sig.emit();
assert(cnt == 1);

// disconnecting by destroying/overwriting the connection object
sig.socket.connect(conn, &slot);
sig.emit();
assert(cnt == 2);
conn = SignalConnection.init;
assert(!conn.connected);
sig.emit();
assert(cnt == 2);

// disconnecting through the signal
sig.socket.connect(conn, &slot);
sig.emit();
assert(cnt == 3);
sig.disconnectAll();
assert(!conn.connected);
sig.emit();
assert(cnt == 3);

// disconnecting by destroying the signal
sig.socket.connect(conn, &slot);
sig.emit();
assert(cnt == 4);
destroy(sig);
assert(!conn.connected);
sig.emit();
assert(cnt == 4);

Meta