We update our ember.js app and backend API constantly. Sometimes twice a day. So we need an approach to silently update client-side app, so user won’t notice that.
My current idea is:
notify client-side about new version available (long-poll/web-socket)
client-side use iframe/web-worker to download new version as background activity
when any router transition happens stop it, copy URL and reinit page with that URL (window.location = URL). Since scripts already cached at previous step transition should be smooth
At a first glance properly designed ember-app should work that way, but I’m not sure. How do you think guys?
I wrote a bit on this subject recently here: http://cball.me/realtime-app-version-notices. It’s using a mix of technologies but maybe it will be of some help. To do this transparently in ember, I’d set a property when the socket message comes in, and check for that property in a willTransition hook. If the property is set you can grab the url and reload the page. If you’ve set up your routing correctly then the user should be right back where they left off.
I want to wait until transition is done becuase it might be aborted by user (unsaved changes warning) or it’s a
complex transition with redirects and/or replaceWith
simple window.location.reload() is better because I don’t have to use non-public ember API (router.generate)