launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #06558
Re: YUI event for updated context
Hi Francis
>> One question on the hook-up: any specific reason to do one global event
>> containing all the changes, instead of one event per change? Instead of
>> subscribing to lp:context:changed event, subscribing to
>> lp:context:web_link:changed ? So that call sites don't have to parse the
>> changed_fields? Or even more struture, have the cache JSON object be proper
>> Attribute-based object on which we could subscribe on the fooChange event
>> (http://developer.yahoo.com/yui/3/examples/attribute/attribute-event.html)?
>
> I did consider a field by field update event, but there is always the
> possibility that a particular page my have conditional updates, and
> I got convinced not to.
>
I was the one who convinced Tim to do one event containing all the
changes per "unit of work". Publishing individual events for each field
change can and does lead to race conditions that are difficult to debug.
It won't initially be the case for our usage, but as we adopt and use
this sort of infrastructure more and more over time, and the use cases
become more complex, it will happen. Consider it analogous to database
transactions where you only see all the changes together once the
transaction is committed. This issue will become more relevant and
important if/when we start using techniques to allow change
notifications pushed from the server to each client. It also becomes
more relevant when the idea of content based filtering is considered. ie
we want to do something based on a match filter applied to the result of
a unit of work. It's harder to implement this with just individual
property change notifications.
Having said that, there's nothing to prevent the addition of helper
methods/classes to make notification and processing of individual field
changes easier for those simple cases which require it. ie we can ensure
the implementation can "devolve" to the simple case.
The above are all high level, domain independent thoughts but I think
they're applicable whether we're talking about client side or server
side. For Launchpad as it exists today, we could initially get away with
simple field level change notification. As I say above, we can indeed
provide that but I just want to be sure we are aware of and consider
future implications (and possibly ingraining bad habits early) when
doing this sort of new infrastructure development.
References