Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Model.observeObject vs element.addEventListener()
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
johnjbarton  
View profile  
 More options Aug 17 2011, 12:50 am
From: johnjbarton <johnjbar...@johnjbarton.com>
Date: Tue, 16 Aug 2011 21:50:17 -0700 (PDT)
Local: Wed, Aug 17 2011 12:50 am
Subject: Model.observeObject vs element.addEventListener()
As far as I can tell from reading,
http://mdv.googlecode.com/svn/trunk/docs/model.html
the Model mechanism is a separable layer from the rest.

By itself this mechanism generalizes and shifts around the event
system.

Generalizes because any JS object can be observed (well to be sure,
models are observed and any JS object can have a model).  Also
generalizes because the change event verbs come from a fixed set, [add/
delete, value-change], vs open set defined by the object.

Shifts around because now the observer thinks it is directly wired to
the object. In fact the model intervenes, but from the API point of
view the programmer thinks about the target object and the changes on
that object that are of interest. In the DOM event system on the other
hand, the programmer first thinks about the event, then about the
object. For example, the programmer first thinks about "load event"
then "target is document" or "click event" then "target is element".

Am I on the right track? Seems like this separate part could be used
in inter-module signalling quite apart from the template bits.

jjb


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rafael Weinstein  
View profile  
 More options Aug 17 2011, 1:18 pm
From: Rafael Weinstein <rafa...@chromium.org>
Date: Wed, 17 Aug 2011 10:18:24 -0700
Local: Wed, Aug 17 2011 1:18 pm
Subject: Re: Model.observeObject vs element.addEventListener()
Unfortunately this document needs to be updated. But I'm interested in
your use case.

On Tue, Aug 16, 2011 at 9:50 PM, johnjbarton

<johnjbar...@johnjbarton.com> wrote:
> As far as I can tell from reading,
> http://mdv.googlecode.com/svn/trunk/docs/model.html
> the Model mechanism is a separable layer from the rest.

> By itself this mechanism generalizes and shifts around the event
> system.

> Generalizes because any JS object can be observed (well to be sure,
> models are observed and any JS object can have a model).  Also

Yes. Though, we have concluded that the ECMA Proxy.create() mechanism
currently isn't an net win as a mechanism for observing objects, and
we have "turned off" it's usage in our model abstraction. Now, the
model mechanism always just dirty checks all observed values.

Also, the API has changed somewhat. See the current Model.js file for details.

> generalizes because the change event verbs come from a fixed set, [add/
> delete, value-change], vs open set defined by the object.

This is presently true for Object and Array, but we feel that it may
be useful for application-defined objects to define their own verbs.
For instance, the implementation of the Array handler currently
"short-circuits" the stream of property accessed notifications, and
emits a single "splice" mutation "verb" for all array operations.

You can easily imagine that it would be useful for domain objects to
do something similar.

> Shifts around because now the observer thinks it is directly wired to
> the object. In fact the model intervenes, but from the API point of

The big change that has taken place here is that observers are now
notified asynchronously.

> view the programmer thinks about the target object and the changes on
> that object that are of interest. In the DOM event system on the other
> hand, the programmer first thinks about the event, then about the
> object. For example, the programmer first thinks about "load event"
> then "target is document" or "click event" then "target is element".

I'm not sure what you mean here. Can you explain more about this view?

> Am I on the right track? Seems like this separate part could be used
> in inter-module signalling quite apart from the template bits.

Possibly. The model abstraction continues to be completely separable
from the rest of MDV.

I'm curious to hear more about what you have in mind for inter-module signaling.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John J Barton  
View profile  
 More options Aug 17 2011, 2:04 pm
From: John J Barton <johnjbar...@johnjbarton.com>
Date: Wed, 17 Aug 2011 11:04:52 -0700
Local: Wed, Aug 17 2011 2:04 pm
Subject: Re: Model.observeObject vs element.addEventListener()

I'm unsure why this is helpful, other than causing cascading changes
to be stacked on the event queue rather than the call stack.

>> view the programmer thinks about the target object and the changes on
>> that object that are of interest. In the DOM event system on the other
>> hand, the programmer first thinks about the event, then about the
>> object. For example, the programmer first thinks about "load event"
>> then "target is document" or "click event" then "target is element".

> I'm not sure what you mean here. Can you explain more about this view?

The issue here is encapsulation.

The API for the change handler in the MDV case are the properties of
the data proxied through the Model. This is very direct and simple,
but the developer of the |data| needs to treat the properties as API,
not implementation.

The API for the DOM event handler are event properties which may or
may not be proxies for the data. The event can have copies of values
so the handler cannot directly access the corresponding properties.
The event can have a property referring to an API which encapsulates
data.

>> Am I on the right track? Seems like this separate part could be used
>> in inter-module signalling quite apart from the template bits.

> Possibly. The model abstraction continues to be completely separable
> from the rest of MDV.

And this part is similar to eg backbone.js right?

> I'm curious to hear more about what you have in mind for inter-module signaling.

I just mean change signaling unconnected to HTML. For example, an
editor may signal diffs to another tool, via events, eg:
http://orionhub.org/help/index.jsp?topic=%2Forg.eclipse.orion.doc.isv...
or it could use the model observe mechanism.

jjb


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »