I’ve a question about the js generator.
If you take a look at https://try.haxe.org/#23850 you’ll see that instead of relying on the native js binding functionality, the generator creates wrapper-functions that carry the bound parameters within their scope. I think it hasn’t always been this way, but I’m not sure.
The problem we have with this is that you lose the reference to the results of the bind calls, and thus if you use those as listeners (think Observable pattern), you cannot remove them afterwards.
So two questions:
Is the reason for these wrapper-functions merely for code-transparency/debugging purposes, or is there something else I’m missing?
How would you go about changing the generator behaviour if you have legacy code that suddenly turns out to be leaking? What I’ve tried so far is:
- A macro approach which lead me to eventually replace all classes that make use of bind at Compiler.onGenerate and it is not optimal.
- Regular expression replacement in already generated js feels too non-haxe-y to become comfortable with.
- I was hoping there would be a compiler directive that handles this, but couldn’t find one.
What’s left is a custom JS generator, which feels like overkill.
Thanks in advance!