- 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.
- This video is a good summary of the Observer pattern chapter in the book Head First Design Patterns book.
Redux: A use case for the observer pattern
If you work in the world of React, you have probably dealt with Redux to manage the state of your application.
- Redux is an implementation of the observer pattern.
- This method “pushes” new subscribers to the array
const subscribe = (listener) = (
Remember that subscribe is called in the componentDidMount method which fires immediately after the component mounts.
- The Command Pattern is a great pattern for architecting really clean decoupled systems.
- There are several elements to the Command Pattern: the Receiver , Command , and the Executor .
- Let’s get into the Command Pattern, then translate this to Redux.
- Knowing the Command Pattern makes learning Redux a lot easier!
- Design patterns represent the best practices used by experienced software developers.
Read the full article, click here.
@ReactiveConf: “Redux and the command pattern: #ReactJS”
There are two things I know for absolute certainty in the Software industry.
Redux and The Command Pattern – Front-end developer – Medium