Skip to main content
45 votes
Accepted

Are front-end state management tools an anti-pattern?

The problem with global variables is that they are difficult to reason about. Where is that global variable being modified? How would you even know? When you pass around a context object (i.e. a ...
Robert Harvey's user avatar
23 votes

Are front-end state management tools an anti-pattern?

The quote from the book is concerned more about code that looks like this: var data = { some: { huge: { deeply: { nested: { object: { ...
Greg Burghardt's user avatar
6 votes

Is Redux using a sanitized God object pattern?

What is a God object? From Wikipedia: Most of [a God object containing] program's overall functionality is coded into a single "all-knowing" object, which maintains most of the information about the ...
Daniel T.'s user avatar
  • 3,063
5 votes

Redux LOADING/SUCCESS/ERROR pattern - when using redux-saga

Yes this pattern will apply well with redux saga. Think of redux saga as just a middleware layer within Redux. Basically when you dispatch an action in your code, redux saga will intercept that ...
dane's user avatar
  • 51
4 votes

Are front-end state management tools an anti-pattern?

While other answers here are completely valid I want to give an alternative perspective that frontend data stores CAN be an anti-pattern in certain situations. In the component hierarchy used by React ...
rubyuser1357796's user avatar
4 votes

when would I need state management like redux in my e commerce app?

In a nutshell, the client app states have little to do with the business data. Of course, some business data might be referred or held by the client's state, but it's contextual. Not mandatory. When ...
Laiv's user avatar
  • 14.9k
4 votes
Accepted

react-redux (React bindings) vs Virtual Dom and Single responsibility principle

react-redux at the end provides a convenient way of accessing the store from any component (actually, as the documentation says, only container components should connect to the store). This means that ...
Mario F's user avatar
  • 226
4 votes
Accepted

Best Practice for handling data sync with React Native, MobX and REST?

The best practice is to use persistent storage which facilitates offline-first development and offers built-in client/server data sync, such as PouchDB/CouchDB: The PouchDB API provides a method for ...
3 votes

How to structure a REST API response for a Flux/Redux frontend?

An equally good argument to normalize or flatten nested data is when it comes to updating this data. This is well explained here. Because this is a common use-case, Dan Abramov created normalizr, ...
Vincent Sels's user avatar
2 votes

React / GraphQL / Redux design question: Looking for a good practice

Right on the front page of the Redux website is a link to an article saying: You Might Not Need Redux. It is well worth a read since it explains very clearly what you gain by using Redux and what you ...
Berin Loritsch's user avatar
2 votes

Is Redux using a sanitized God object pattern?

IMO, The above question should not arise. Functional programming concepts are not comparable to concepts in OOPS, they are just different ways of solving same problem.
Anand's user avatar
  • 181
2 votes

how to design redux actions involving chained side effects?

In general, just look for the message that has enough data to be actionable. For example, if a websocket passes a message, add that to the store: myWebSocket.onmessage = function (event) { store....
2 votes

When using Redux/Redux-Saga - should JWTs be set in the action creators/sagas?

For me the main reason to store the token in local storage instead of redux store is that they are fundamentally different in nature in that: You usually want too keep the auth token between page ...
Tiago Coelho's user avatar
2 votes

When using Redux/Redux-Saga - should JWTs be set in the action creators/sagas?

I will do a guess from different sources. I heard "security is not a crosscutting concern" I would put authentication in it. It can not be separated from the program although not included in the model ...
User's user avatar
  • 815
2 votes
Accepted

What do you call the state reducer pattern used by redux?

As mentioned in a comment, the pattern is called a "fold", which many other languages implement as a function called "reduce" -- thus redux's name for it. Wikipedia's page is as usual a firehose of ...
Chuck Adams's user avatar
2 votes

Are ViewModels within an NgRX store an anti-pattern?

I don't think it's "bad practice" as long as it works fine for you. One think you should consider, however, is that you might be omitting one of the strengths of NgRx: Memoization. Selectors ...
null1's user avatar
  • 164
1 vote

How to actually use global state in React?

Choosing to use global state libraries like Redux or MobX in React often comes from past decisions and their benefits. Many older projects started with Redux because it was popular and now find it ...
Jimmy Kurian's user avatar
1 vote

Organizing Data with Specific Group in Objects and Lists

References are wonderful things. If you really need something to be an object, and to be available in two locations, then consider passing references to that one object to those two locations. Do ...
candied_orange's user avatar
1 vote

How could I reuse common JS modules between several projects?

Yes, I actually did something similar for my work. The context for me was that there was a particular set of utility functions (parsers, generators, readers) that dealt with a particular data ...
Bharath CS's user avatar
1 vote

How to effectively handle 404/500 http errors in server-side rendering web application which uses store for state?

If you're working on a server side rendered app, redux and react router seem like the wrong tools for you. The reason you're having difficulty is because you're taking a reasonably state-light ...
Dan Monego's user avatar
1 vote

"Fetch the data if it doesn't exist" selector?

Sounds like a typical scenario for HOC (higher-order-component) or RenderProps if you prefer it that way. The component would receive the action type that needs to be fired and does so on it's ...
andras's user avatar
  • 212
1 vote
Accepted

Should / When to create javascript object to serialize data?

If javascript were a pure object oriented programming language, I would have recommended to you to create an object to encapsulate data with behavior, since it's the very purpose of OOP. By doing that,...
Pierre Criulanscy's user avatar
1 vote

React: Redux vs Singleton service

It's a bit late in the day, but I've been asking a similar question recently. It does seem to me that a well designed layer of singleton services (using RxJS) can (and should!) replace most of the ...
kapilkaisare's user avatar
1 vote

Organizing reducers in Redux

I have come up with a solution where I simply don't consider the next available id as part of the app state. In my actions.js, I have added a counter that simply increments whenever addTodo is called:...
Derek 朕會功夫's user avatar
1 vote

Redux: When Should I Keep Track of State and When Should I Not?

Redux should hold "persisted" app state. By persisted I mean state that persists across component mounting/dismounting. This tends to be things like user data and application data that has been ...
Samuel's user avatar
  • 9,237
1 vote

What is a (Redux) selector?

From Laiv's comment and What are selectors in redux? a Redux selector is a function that knows how to extract a specific piece of data from the store.
1 vote

Does AngularJS or Angular 2 provide something similar to the Redux middleware so that AJAX data appear immediately available?

It sounds like you're referring to redux-promise, which abstracts away the work of creating your own promise-handling functionality that dispatches (or not) after the promise is done. This abstraction ...
Way Spurr-Chen's user avatar
1 vote

Functional model vs data model and react/redux

This sounds like a good use case for the Reselect helper library. You want to keep your Redux state (and, by extension, the reducers) as simple as possible, so only include the input parameters for ...
Alistair Green's user avatar
1 vote

How do I manage dependant values without running the same computation twice?

This should really be a comment under Doc Brown's answer, but I don't have enough reputation to write comments yet. There is an add-on library for Redux called Reselect which is designed to tackle ...
Alistair Green's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible