Closed mrakgr closed 1 year ago
I'm afraid I have no idea what that code does (I never did F#)... What do you mean by Handler removal?
For example...
this.Nodes.remove_Added handler_node_add
This in F# would be equivalent to...
this.Nodes.Added -= handler_node_add;
...in C#. The C# language uses the +=
and -=
operators, but the Added
event gets compiled down to add_Added
and remove_Added
, and this is how we can access them from F#. For some reason the removal is not working as it should.
I'm not sure this would be an issue of the library then no? It works fine in C#
Yeah, it works fine in C#, and on a toy example in F#. I am completely perplexed as to why it doesn't on the example above. Maybe some compiler optimization is causing the references to get inlined? Anyway, it is not the fault of the library.
Repo: https://github.com/mrakgr/helix/blob/b4ff8b87095ce370660101c39dc993bb11760701/Helix.Fun/Helix.Nodes.fs#L140
I am working on undo/redo functionality so I thought of suppressing the event firings by removing the handlers, but it doesn't seem like removing them here does anything, as they still get triggered. Due to removal not working, I've run into issues where they get added multiple times.
Anyway, I've tested it and it seems they get fired right away instead of being queued, so that will allow me to use a mutable variable as a switch to suppress them, instead of removing them like this.