Signal.connectFirst

Add a handler to the list of handlers to be called when emit() is called. Add this handler at the top of the list, so it will be called before all other handlers.

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

Return Value

Type: T

The handler that was passed in as a paramter

bool firstCalled, secondCalled;
@safe void handler1() {firstCalled = true;}
@safe void handler2()
{
    secondCalled = true;
    assert(firstCalled);
}
Signal!() onTest;
onTest ~= &handler2;
onTest.connectFirst(&handler1);
onTest();
assert(firstCalled && secondCalled);

Throws

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

Meta