Tips For a Better Redux Architecture: Lessons for Enterprise Scale

Hashnode Original


Write your comment…

This comment has received 3 appreciations.

If you were using redux-define you could reduce the boilerplate of defining action types.

Especially when using status suffixes like ERROR or SUCCESS, it can make a big difference.

Turning your example

export const ADD_TODO = 'todos/ADD_TODO'
export const ADD_TODO_SUCCESS = 'todos/ADD_TODO_SUCCESS'
export const ADD_TODO_FAILURE = 'todos/ADD_TODO_FAILURE'


export const ADD_TODO = defineAction('ADD_TODO', [SUCCESS, FAILURE], 'todos');

Yes it's mine. I should have mentioned that. I use it with redux-actions and redux-saga like the example in the readme. And really like the now obvious separation between actions and status updates. While having less boilerplate.

Write a reply...

This comment has received 1 appreciation.

Very nice post @michaelgilley I'm implementing a similar approach you proposed for my PoC.

Write a reply...

This comment has received 1 appreciation.

This all can be done much simpler and more declarative than Redux Saga. You have to look at Cerebral's signals and it's excellent function tree, it can be used not only in Cerebral, but also in Redux or Mobx.

Thanks for the tip @hipertracker. I haven't looked at cerebral yet. I'll have to read more about it and see how it compares.

Write a reply...

Thanks a lot! I've been struggling to maintain a disorganized app for a long time, but I think the concepts you have presented here will do the trick!

Write a reply...

For importing module across features i like Jack hsu ( implementation.

Yes, that scheme is very close to Ducks as well and there are several different ways to stash the modular components of a Redux app. Perhaps the most important is uniformity in design across modules. Also, while I do like the separation of each type into separate files this would also have the disadvantage of even more boilerplate code/structure to manage per module. Thanks for the post!

Write a reply...

Load more responses

Join a friendly and inclusive Q&A network for coders

  • 🖥Pick the technologies you like & read great content through your feed.
  • 💬Ask a question when you want to learn more about anything.
  • 🚀Share what you know & build your portfolio.
Sign up nowLearn more

loading ...