Experimental implementation of Object.observe & JS Utility library now available

Alex Russell slightlyoff at google.com
Tue Aug 14 03:30:13 PDT 2012


On Tue, Aug 14, 2012 at 10:33 AM, Andrea Giammarchi <
andrea.giammarchi at gmail.com> wrote:

> just seen it, looks like an improved alternative to the good old, non
> standard, Object.prototype.watch


Key differences include:

  * unlike watch(), you can be informed not only of deletions but also
additions to objects
  * delivery is async-ish (huzzah!)


> ... but
>
>    1. records are not "struct like", properties might be or might not be
>    there rather than being there with undefined values ... is this heading to
>    not optimal performances in V8 and others?
>
> I don't understand. New objects with fixed-ish shape have fixed-ish shape
through their lifetimes. It's unclear what the problem is here.

>
>    1. how is the memory consumption preserved with freshly new created
>    record objects, rather than a single callback as entry point and simply
>    oldValue, newValue passed as arguments?
>
> These objects are disposed at the end of the current turn (assuming you
don't hold on to them forever).

>
>    1. why the callback is not simply something like observer(type,
>    object, property, oldValue, newValue) so that a single callback can be
>    still recyclable and no object is created per each change, plus it's easier
>    to retrieve the new value rather than passing through record.object[
>    record.name] ?
>
> Having the full list is critical for dealing with inter-related changes
that happen in a second turn. You often care about the high-level semantic
action, not just the immediate change to some property.


>
>    1. what is the context of each notify call? (this might be in specs
>    already, so I'll check there too)
>
> I know it's strawman already but if anyone can explain me these points
> that would be great, cheers.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120814/40f66277/attachment.html>


More information about the es-discuss mailing list