issue with un-registering event handlers in codemirror

When turning on the cursorActivity with cm.on("cursorActivity", function (instance) {});
I tried turning off with"cursorActivity", function (instance) {}); to no avail.

I’ve noticed that cm._handlers is receiving multiple cursorActivity handlers. Since I am only using this single handler, I went on to delete cm._handlers.

I reckon the above would be considered a bad practice, especially when scaling and adding new handlers in the future.

Can you confirm if my off method is bad, or this is a bug?

Two function literals, even if they have the same body, aren’t equal. You have to give the original function you pass to on a name, so that you can pass the identical value to off.

1 Like

Many thanks.