The 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.
  • 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.

Continue reading “The Observer Pattern In Javascript”

How to Port Your Native Modules into a React Native Environment

Port your native modules into a React Native environment:  #ReactJS #JavaScript

  • 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.

  • What’s very nice about this design pattern is that by having the wrapper simply wrap around the SDK, we’re letting the native SDK do the heavy lifting of lifecycle management, but allowing ourselves the flexibility to design the interface back to Javascript:

    Once we know we can hook into the iOS lifecycle methods and have the middleware “listen” to these lifecycle events, we can write the Javascript portion of the SDK to receive notifications when an event occurs.

  • For developers using React Native with Branch, it’s a matter of tapping into the Javascript function that connects to the RNBranch methods, and doing all the cool things they do with Branch, like receive deep link data, save custom events, and create shareable links, without having to worry about messy or complicated hooking into native code.
  • Branch found a relatively straightforward way to port into React Native without spending a bunch of time re-writing the Native SDK into a Javascript environment.

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”

Redux and The Command Pattern – Front-end developer – Medium

Redux and the command pattern:  #ReactJS

  • 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