Summarizing

Our cleanup started with the view; we wanted to remove a direct connection to the dispatcher and also stop having to use magic strings as this is quite error prone, and it's easy to misspell. Instead, we can rely on constants. To remedy this, we created an action creator class that talked to the dispatcher instead.

We also created a constants module to remove the magic strings. 

Furthermore, we improved the store by starting to use EventEmitter. Finally, we further improved the store by adding more actions to it and also started to refer to the constants.

At this point, our solution is ready for more actions to be added to it and we should feel pretty clear on what files we need to add to, as we support more and more user interactions.

Lastly, we added improvements around ES2015 and immutability, which made our code look a lot cleaner. With this foundation, we are now ready to go from static data to involve working with side effects and Ajax in the upcoming section.

Let us summarize all our improvements in a diagram showing the constructs added to our flow:

It is clear that using an action creator isn't strictly necessary but it does clean up the code quite a bit, and the same goes for using an EventEmitter in the store; it's nice but not necessary.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.93.168