The Observer Pattern In Javascript as Implemented By Redux

Click for: original source

James Buczkowski post on hot topic of Observer pattern in JavaScript. The observer pattern, also referred to as the publish/subscribe pattern, is a design pattern where an object (called the subject or observable), will maintain a list of “dependents” called observers. Upon a state change, this subject will notify any of the observers automatically.

There are usually 3 methods involved. One method to register an observer. One to remove an observer. And finally, one that will notify the list of subscribers of the change.

If you work in the world of React, you have probably dealt with Redux to manage the state of your application.

Author then discuss polling and push as 2 main means for class when it needs to keep track of something, or better yet, know when something has happened.

Video (~50 minutes long) is also attached with good summary of the Observer pattern together with the link to a book. Plus example code. Good read.

[Read More]

Tags software-architecture javascript react