- 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.
- Additionally, this middleware object–written in Objective-C–can interface with other Objective-C code, thereby letting us wrap around our existing native SDK calls, like initNewUserSession.
- In the example below, notice how these functions in the middleware mirror exactly what our native SDK provides:
Now that we have a nice middleware object, we need the Objective-C environment to be aware of it.
Learn more about how to port your native modules into a React Native environment, with this comprehensive guide from Branch.
Continue reading “How to Port Your Native Modules into a React Native Environment”
- 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