Signals and Slots
I spent some time this weekend implementing a signals and slots class for haXe. This method of event handling is often useful for managing GUI’s, since GUI control code is often defined in separate classes from GUI display code, and yet they’re very similar in terms of input/output. Provisions/expectations of the controls and views (resp.) are often identical in terms of their parameters (Mouse moves to position X:Y…. Cursor Image moves to position X:Y, etc.). Rather than falling back on boilerplate Event code, signals and slots let’s you stitch together relevant function calls externally from the Class(es) that define them.
The drawbacks that I’ve run into (in haXe) are that I’ve had to rely heavily on Dynamic types, which obviously can’t be checked at compile time. Furthermore, memory leaks are problematic if you’re not careful to remove all the signal handlers. However, I think this still would be useful in certain situations.
Check it out on google code!





Trackbacks & Pingbacks