Permalink
Browse files

reload based on appHash in production as well

  • Loading branch information...
1 parent 0ad5b54 commit dab3c6dbb3cac1291554808635f195d2a37ca213 @nateps nateps committed Oct 9, 2012
Showing with 12 additions and 15 deletions.
  1. +6 −1 lib/derby.browser.js
  2. +3 −5 lib/derby.server.js
  3. +1 −7 lib/refresh.js
  4. +2 −2 lib/refresh.server.js
View
7 lib/derby.browser.js
@@ -82,7 +82,12 @@ function init(modelBundle, appHash, debug, ns, ctx) {
// The ready event is fired after the model data is initialized and
// the socket object is set
racer.on('ready', function(model) {
- if (debug) autoRefresh(view, model, appHash);
+ model.socket.on('connect', function() {
+ model.socket.emit('derbyClient', appHash, function(reload) {
+ if (reload) window.location.reload(true);
+ });
+ });
+ if (debug) autoRefresh(view, model);
view._afterRender(ns, ctx);
});
racer.init(modelBundle);
View
8 lib/derby.server.js
@@ -76,11 +76,9 @@ proto = {
view._derbySettings = settings;
view._appFilename = appModule.filename;
- if (!isProduction) {
- racer.on('createStore', function(store) {
- autoRefresh(store, settings, view);
- });
- }
+ racer.on('createStore', function(store) {
+ autoRefresh(store, settings, view, isProduction);
+ });
// Expose methods on the application module
View
8 lib/refresh.js
@@ -17,15 +17,9 @@ function errorHtml(errors) {
text + '</div></div>';
}
-function autoRefresh(view, model, appHash) {
+function autoRefresh(view, model) {
var socket = model.socket;
- socket.on('connect', function() {
- socket.emit('derbyClient', appHash, function(reload) {
- if (reload) window.location.reload(true);
- });
- });
-
socket.on('refreshCss', function(err, css) {
var el = document.getElementById('$_css');
if (el) el.innerHTML = css;
View
4 lib/refresh.server.js
@@ -20,7 +20,7 @@ function templateError(err) {
return err.stack;
}
-function autoRefresh(store, options, view) {
+function autoRefresh(store, options, view, isProduction) {
if (!store.sockets) {
store.once('setSockets', function() {
autoRefresh(store, options, view);
@@ -48,7 +48,7 @@ function autoRefresh(store, options, view) {
}
}
callback(reload);
- if (reload) return;
+ if (isProduction || reload) return;
appFilename = view._appFilename;
if (listeners[appFilename]) {

0 comments on commit dab3c6d

Please sign in to comment.