π 1/8 JS Reactive Patterns: PubSub or Publish-Subscribe
#js #patterns #pubsub
#js #patterns #pubsub
PubSub is one of the most commonly used and fundamental reactivity patterns. The Publisher is responsible for notifying Subscribers about the updates and the Subscriber receives those updates and can react in response.
One popular example of its usage is Redux. This popular state management library is based on this pattern (or more specifically, the Flux architecture). Things work pretty simple in the context of Redux:
β Publisher: The store acts as the publisher. When an action is dispatched, the store notifies all the subscribed components about the state change.
β Subscriber: UI Components in the application are the subscribers. They subscribe to the Redux store and receive updates whenever the state changes.
π3β€1π₯1