-
Notifications
You must be signed in to change notification settings - Fork 17
Reloading Controllers In Development
As mentioned in the controller Wiki, WebsocketRails controllers are continually running. Each action is processed by the same instantiated object. This makes it great for keeping state between events, however it means that the controllers do not get automatically reloaded during development and code changes will not be picked up until you restart the server.
To make the development process less painful, we have added an internal event that you can trigger to reload the changes you have made to your controller without restarting the server.
The name of the event is websocket_rails.reload!
. It can only be
triggered while your application is in development or test mode.
Assuming you have already loaded up your dispatcher, you can trigger the controller reload with the following line:
dispatcher.trigger('websocket_rails.reload!');
This will reload all of your controller changes without dropping any
connected clients or resetting any data you have in the DataStore
.
I recommend adding a button that appears on your site if you are in development mode that you use to fire the reload! event.
Hopefully soon we can add a view helper that can take care of this for you. Allowing you to do something in your view such as:
<% if rails.env.development? %>
<%= websocket_reload_button_tag %>
<% end %>
Or something along those lines.
Until then, you must fend for yourselves
and write your own button or trigger the websocket_rails.reload!
event
through the JavaScript console.