Signal.connect

Add a handler to the list of handlers to be called when emit() is called. The handler is added at the end of the list.

struct Signal(Types...)
@trusted
T
connect
(
T
)
if (
isHandler!(T, Types)
)

Return Value

Type: T

The handler that was passed in as a paramter

Throws

Exception if handler is already registered (Only if asserts are enabled! Does not throw in release mode!)

Examples

int val;
string text;
@safe void handler(int i, string t)
{
    val = i;
    text = t;
}

Signal!(int, string) onTest;
onTest.connect(&handler);
onTest(1, "test");
assert(val == 1);
assert(text == "test");

Meta