Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MochiKit.Signal with GC #26

Open
blq opened this issue Dec 1, 2018 · 0 comments
Open

MochiKit.Signal with GC #26

blq opened this issue Dec 1, 2018 · 0 comments

Comments

@blq
Copy link
Member

blq commented Dec 1, 2018

Hi,
This is a kind of RFC before going to PR.
In my fork I've now added a major under-the-hood update to MochiKit.Signal lib.
It uses WeakMap and Set to store references to signals to enable automatic GC.
Should also be faster due to less linear searches.

See: https://github.com/blq/mochikit/blob/master/MochiKit/Signal.js

All unit-tests pass except one, disconnectAllTo(function) since WeakMaps doesn't allow full iteration and I wanted to reduce WeakMaps to only source and dest objects, not functions.

Observe that this setup doesn't remove need to disconnect of course, WeakMaps only release fully GC:ed objects, it's not an out-of-your-scope release.


Another change in my fork is support for signal namespaces, similar to jQuery. That is a separate discussion I guess..
(WeakMap means IE10 is out, but code is written to still work in IE11 (no for-of loops or such))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant