Using ES6 classes with Redux

I am working on a project that brings a ton of data from one endpoint to one gearbox. I would like to convert this data to ES6 classes, so I can give them a helper method, ensure the relationship between the data and not work with regular javascript objects all the time. Also, in order to get the relationship between the data, I have to do n-square calculations and slow down the external interface.

Here are the options I see:

1) Create a selector that connects to the redux repository. This selector could receive data from the gearbox and convert it to several ES6 classes that I defined. If the reducer receives new data that is different from each other, the selector recreates instances of ES6 classes.

2) https://github.com/tommikaikkonen/redux-orm This also seems fantastic.

3) Create some selectors in the dataset that will calculate the specified relation in the dataset, so I can just call this selector every time I want to get the relation, which otherwise would be computing n-squares to get,

My question is which of the three should I take? Is there an alternative besides these 3? Or people just work with javascript objects mainly on the interface and do not deal with ES6 classes.


Update:

Two months later, and I'm still using Redux-ORM in production, and it's fantastic! Highly recommend.

+5
source share
1 answer

Of course, it is entirely possible to do all this with the help of "simple" functions and selectors. There is normalization information in the Redux FAQ , and I have some articles on selectors and normalization as part of my React / Redux link list .

However, I am a big supporter of Redux-ORM. This is a fantastic tool for managing normalized / relational data in your Redux store. I use it to normalize embedded data, query data, and constantly update data.

My hands- on Redux blog blog includes two Redux-ORM articles: Redux-ORM Fundamentals and Redux-ORM Concepts and Techniques . The last article, Practical Redux Part 5: Loading and Displaying Data , also shows Redux-ORM.

The author of Redux-ORM, Tommy Kaikkonen, actually just posted a beta version of the main Redux-ORM update, which improves the API and behavior that I look forward to playing with.

I definitely recommend it!

+7
source

Source: https://habr.com/ru/post/1261228/


All Articles