[Vala] Run signal once



Hi,

While programming with signals it happened many times that I wanted to connect signal, but run it only once.
So, I was doing it like this:

ulong id = 0;
id = object.signal.connect(() => {
    do_something();
    object.disconnect(id);
});

This looks a bit complicated, and more like a workaround, not a real solution.
Is this a good solution, or I'm missing something?

Thanks!




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]