[nycphp-talk] the stale V in MVC web apps
John Campbell
jcampbell1 at gmail.com
Wed Mar 4 11:50:34 EST 2009
I use AJAX polling loops to check if the data is actually stale, and
then do something about it. It can be complicated as auto updating
the sections of the page that have changed, and then doing the
"yellow-fade". If you don't want to get fancy, you could just show a
dialogue that let's the user know the data is stale, and give them the
option to refresh.
Writing an ajax polling loop is really quite simple... just make sure
you use tail recursion, rather than an interval. I have made that
mistake in the past, and it hurts.
Dont do:
setInterval(checkStatus,3000);
Do:
// checkStatus must have a callback parameter when complete.
(function() {
var this_function = arguments.callee;
checkStatus(function(){
setTimeout(this_function,3000);
});
})();
On Wed, Mar 4, 2009 at 10:49 AM, David Mintz <david at davidmintz.org> wrote:
>
> I've got users working collaboratively all day long on a set of database
> records. The view in front of them is frequently stale. A common old Web 1.0
> approach to solve this was to reload the page automatically every n seconds
> with a meta refresh. Nowadays we have xhr. Either way, my concern is as the
> W3C points out, an unexpected refresh can disorient users.
>
> I have thought of displaying a thingy at page load time that says "reloading
> automatically in 5 minutes" and then updating via Javscript it to count
> down 4, 3, 2 and after maybe 30 seconds start counting off seconds, then
> update via ajax. The upside is they won't get (or at least shouldn't be)
> surprised. The downside is more clutter, potentially annoying and/or
> distracting. But I think you could put a discrete little timer thingy that
> ought not be too irritating.
>
>
> What do YOU do about this sort of thing?
>
> --
> David Mintz
> http://davidmintz.org/
>
> The subtle source is clear and bright
> The tributary streams flow through the darkness
>
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>
More information about the talk
mailing list