vala Signals Default handler and connect_after


Signals can have a default handler. All you need to do is to give it a body when you declare it.

public class Emitter : Object {
    public signal void my_signal () {
        print ("Hello from the default handler!\n");

This handler will always be called after the connected ones. But you can use connect_after instead of connect if you want to add an handler after the default one.

var emitter = new Emitter ();
emitter.my_signal.connect_after (() => {
    print ("After the default handler!\n");
emitter.my_signal ();