Skip to content

MochiKit.Signal with GC #26

@blq

Description

@blq

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions