Signal.connectAfter

Add a handler to be called after another handler.

struct Signal(Types...)
@trusted
T
connectAfter
(
T
U
)
if (
isHandler!(T, Types) &&
isHandler!(U, Types)
)

Parameters

afterThis T

The new attached handler will be called after this handler

handler U

The handler to be attached

Return Value

Type: T

The handler that has been connected

Throws

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

Exception if afterThis is not registered (Always, even if asserts are disabled)

Examples

bool firstCalled, secondCalled, thirdCalled;
@safe void handler1() {firstCalled = true;}
@safe void handler2()
{
    secondCalled = true;
    assert(firstCalled);
    assert(thirdCalled);
}
@safe void handler3()
{
    thirdCalled = true;
    assert(firstCalled);
    assert(!secondCalled);
}
Signal!() onTest;
onTest ~= &handler1;
onTest ~= &handler2;
auto h = onTest.connectAfter(&handler1, &handler3);
assert(h == &handler3);
onTest();
assert(firstCalled && secondCalled && thirdCalled);

Meta