Closed millermedeiros closed 13 years ago
for now the best solution seems to be setting the first argument of the handler to be a reference to the SignalBinding
- since it has references to everything else..
didn't implemented this way since the beginning because AS3-Signals doesn't do this way (it only passes the variables that you are dispatching).
will probably wait for some opinions and maybe even contact Penner and Joa about it.
since I didn't got any feedback about it in the last 2 months I'm probably going to add SignalBinding as the first parameter of callbacks even if that cause existing code to break... this library didn't reached v1.0 so I guess it's better to fix this problem sooner than later.
implemented in a new branch: 8d4dc6c18ff5f1c55be74f0b7968ed05bd0c899a - not sure if I will merge into master yet...
Could you elaborate on the necessity of sending the SignalBinding through every signal dispatch?
In other words, I would rather keep a general-purpose Signal that can dispatch anything or nothing, and have a different signal class that enforces a convention.
I had this idea when I was planning to create a display list for canvas and I thought that having a way to access the binding from inside the handler could help to easily detach listeners and stop propagation, specially since JS have the same scope issues as AS2... another reason is that having access to the binding on the parameters you could potentially use the same handler for multiple signals (like mouseover/mouseout) and still be able to detach/halt and know which signal is triggering the handler.
I think most of the use cases for this feature that I could think off are just bad practices or edge-cases. As you said, creating a new kind of Signal would probably be a better solution or just change the application structure to circumvent this. I probably won't add this feature unless I need it or someone asks for it. I was keeping it as open because I was waiting for feedback...
it would make it easier to remove the binding from inside the handler, stop propagation, etc.
that is something that could be really helpful but I couldn't find a proper way to do it yet without relying on weird conventions/hacks or changing the way Signal works. - It is more a conceptual problem than anything else.