I am wondering what is the best design approach between using a big state (store) and sql request in database. Let's say you have a Todo CRUD application. You can save the Todos list in store within Redux implementation. What is the best approach if you want to make complex statistics on those TODOs: Reducers or sql requests?
For example, you want to get all todos for the current month:
- Reducers/store approach
You can get all the todos list from the store and filter todos by date to get all todos for the current month.- Pros:
CRUD actions easy to manage, one state changes in the store (todos list)
Low client/server traffics - Cons
Business logic on client side
client overhead for large data processing
- Pros:
- Sql request approach:
Complex request in database to get those todos and save the state 'currentMonthTodos' in the store. In this case you get your current month Todos list from currentMonthTodos state- Pros:
Business logic on server side
Reducing page load time for large datas - Cons
Poor state management for CRUD actions
High network traffic
Size of the store grows up
- Pros:
Aucun commentaire:
Enregistrer un commentaire