Updates to Object.observe

Erik Arvidsson erik.arvidsson at gmail.com
Wed Jul 18 15:04:51 PDT 2012

On Tue, Jul 17, 2012 at 6:54 PM, Rick Waldron <waldron.rick at gmail.com> wrote:
> 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...

unobserve is not perfect but it is clear and it is used other APIs.
> 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.

Removing all observers would be a breach of encapsulation.

If the callback is missing its value will be undefined and no callback
will be found, making the call a noop.

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

Yeah, this is specified. Object.* don't use [[This]]. The [[Notifier]]
uses [[This]] and the algorithm for notify exits early if the internal
properties are not found.


More information about the es-discuss mailing list