Updates to Object.observe

Rick Waldron waldron.rick at gmail.com
Tue Jul 17 18:54:50 PDT 2012

On Tue, Jul 17, 2012 at 7:49 PM, Erik Arvidsson <erik.arvidsson at gmail.com>wrote:

> We've done a bunch of updates to Object.observe in preparation for the
> next weeks face to face meeting. The updates are based on feedback
> from multiple people but more feedback is always welcome.
> http://wiki.ecmascript.org/doku.php?id=strawman:observe


This is really shaping up nicely!

I have a only a few small pieces of feedback at the moment and I apologize
in advance, because the first is definitely bikeshedding.

The term "unobserve" feels clumsy, mostly because it's not a word, whereas
"unobserved" is a word — but is an adjective, not a verb. Prefixing words
with "un" is done so to reverse them, eg. I zip my sweatshirt, then unzip
my sweatshirt. As a programmer, what I really want to do is "ignore" any
further changes, right? "ignore" is actually the opposite of observe, so it
makes sense that I would...

function log(changes) {
let o = {};

Object.observe(o, log);

o.x = "oh hai!";

Object.ignore(o, log);

There was nothing in the Object.unobserve API that specified the behaviour
of calls that are missing a callback argument — I'd assume that this would
remove all observers from an object.

This might be a can of worms, but what happens when I "borrow" any of these
methods to my own object?

let a = {};
let b = {
  watch: Object.observe

b.watch( a, ... );

As far as I can tell, this will just work as expected.


> --
> erik
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120717/19e55bd1/attachment.html>

More information about the es-discuss mailing list