Weak event listener

Benoit Marchant marchant at mac.com
Mon Mar 25 20:24:17 PDT 2013

Very true, I'm wondering if based on usage today it could make sense to have this as default behavior on current API?


On Mar 25, 2013, at 19:51, Peter Michaux <petermichaux at gmail.com> wrote:

> On Mon, Mar 25, 2013 at 2:55 AM, Marius Gundersen <gundersen at gmail.com> wrote:
>> One thing which is impossible to make in JavaScript today is a weakly
>> referenced event listener system. In such a system an event listener is not
>> strongly referenced by the event system, so events are only dispatched to it
>> as long as another object holds a reference to it.
> Being able to make an observable subject that keeps a weak list of
> observers would be very useful to ease memory management within an
> application and avoid accidental memory leaks at the application
> level. Sometimes the application programmer may forgot to remove a
> observer from an observable subject, for example.
> With regard to the MVC architecture, this could be the best addition
> to the language to make application development easier. A view might
> mistakenly not unsubscribe from its associate model when the view is
> destroyed, for example. That or the view's destroy method is never
> even called because the application programmer forgot to call it.
> Peter
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

More information about the es-discuss mailing list