Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redux and Design Patterns

I've been using Redux for several months and have a good feel for the unidirectional data flow. However, I'm not trained in OOP and Design Patterns. After listening to a talk by Ralph E Johnson my first reaction was that the Observable Pattern is very similar to Redux/Flux flow, is that correct? Where does that analogy break down?

He talks about the Interfaces required to implement Observable Patterns - is this the sort of thinking that the authors of Redux/Flux architecture have in mind when designing these libraries/architectures?

like image 232
Kunal Avatar asked Feb 21 '17 17:02

Kunal


People also ask

Which design pattern is used in Redux?

At its core, Redux is really a fairly simple design pattern: all your "write" logic goes into a single function, and the only way to run that logic is to give Redux a plain object that describes something that has happened.

What are Redux patterns?

Redux is a pattern and library for managing and updating application state, using events called "actions". It serves as a centralized store for state that needs to be used across your entire application, with rules ensuring that the state can only be updated in a predictable fashion.

What is Redux pattern in React?

Redux is a library that acts as a state container and helps managing your application data flow. It was introduced back in 2015 at ReactEurope conference (video) by Dan Abramov. It is similar to Flux architecture and has a lot in common with it.

What are 3 main concepts of Redux?

In this brief introduction to Redux, we'll go over the main concepts: reducers , actions , action creators and store .


2 Answers

Yes, the Redux store itself is a simple observable/pub-sub implementation, with a single "change/updated" event emitter. The use of actions and reducers has some similarities to CQRS and event sourcing as well. See https://redux.js.org/introduction/motivation and https://redux.js.org/introduction/prior-art .

like image 170
markerikson Avatar answered Sep 19 '22 14:09

markerikson


In Redux the State Tree uses the Singleton pattern and the connect method uses the Observer pattern.

Taken from An Obsession with Design Patterns: Redux by Andra Joy Lally.

like image 26
nur_islam Avatar answered Sep 19 '22 14:09

nur_islam