gotchas - RedwoodAdmin/RedwoodFramework GitHub Wiki

Timers

WARNING!!!
JavaScript's native timer functions, setTimeout and setInterval, should not be used in redwood experiments and neither should AngularJS's $timeout provider or any other timer functions from libraries such as jQuery. Using any of these timers will likely cause issues especially if a subject page is refreshed as they cannot be controlled by the redwood framework. Redwood provides its own timeout function, rs.timeout, that can be used instead. It also provides a syncrhonizedStopWatch service which can be used in particular cases. Please read the page on timers for more details.

User input

State changes: in order to keep an experiment from breaking on page refreshes, all user input should be handled using redwood messages. So, when the user clicks a button for instance, no state change should take place immediately. Instead, a message should be sent using rs.trigger or rs.send, and then only when that message is received should any state change take place.

Double-input: It is often necessary to prevent the user from submitting an input twice, before the first one has been processed. A general pattern to prevent this could be: disable the input when the user clicks on it (before sending the message), and then enable it again after processing the message.

⚠️ **GitHub.com Fallback** ⚠️