Time travel is probably one of the most intriguing and fascinating thoughts out there. Einstein’s theories say, it might actually be possible to travel time. Though, as of now it does not seem like happening anytime soon.

Anyway, in the world of programming, a given application is a universe – U, that holds states and these states change over time. This application universe U necessarily is ordered, and non chaotic. These states or at least those that are relevant, maybe captured and replayed or recreated, by traveling back and forth in time. This time travel is made possible and coherent for our application universe U, by using tools like Redux!

Redux makes this possible by following 3 principles:

  1. Single source of truththe state of your whole application is stored in an object tree within a single store
  2. State is read-only – the only way to change the state is to emit an action, an object describing what happened
  3. Changes are made with pure functions – to specify how the state tree is transformed by actions, you write pure reducers.

Courtesy: http://2.bp.blogspot.com/D8_GvAsx55M/VmSRuKR6gUI/AAAAAAAAAUY/8Kspvqn1cgU/s1600/purefunctionrule1.jpg

If you are into frontend technologies and find time travel interesting, redux might draw your attention, might even capture your imagination. Redux directly attacks one of the extremely subtle to fix programming bugs caused by – side effects! This in itself is huge. State changes occur only via reducer actions that execute pure functions. Hence whoever has subscribed to the action, is notified, once state has changed. Changed state, is a new object, though old state held by not yet updated subscribers, still hold valid value or old object, till updated. This ensures coherence, even while change is being propagated through your app. Function purity guarantees predictability, ensuring time travel yielding same state of Universe at any particular point in time, though travelled again and again.

Finally, as all states of your application are available at any instant of time, it is a great boon for debugging and testing the application. Redux seems to be a great tool that can be used not just for the front-end development but can also be equally useful and usable for the back-end as well.

We at Neova have started exploring and reaping benefits of this great library already 🙂

Happy Coding!

Reference

  1. http://redux.js.org/docs/introduction/ThreePrinciples.html
  2. http://www.express.co.uk/news/science/707642/time-travel-could-possible-theory-machine-will-go-back
  3. http://2.bp.blogspot.com/-D8_GvAsx55M/VmSRuKR6gUI/AAAAAAAAAUY/8Kspvqn1cgU/s1600/purefunctionrule1.jpg