Live data from Hacker News

Redux-query – A React/Redux library for querying and managing network state

amplitude.engineering

51–60 of 63 posts

Re: Redux-query – A React/Redux library for querying and managing network state

#51

I've been experimenting with using a component to fetch data. The data to fetch is declaratively described as props. https://github.com/limscoder/react-wrangler It uses immutable and allows for time travel debugging.

That's a really neat approach. I like how it allows you to trigger code on missing paths. That seems like a really simple way to model an API.

Re: Redux-query – A React/Redux library for querying and managing network state

#52
post #12

Earlier quoted context omitted.

The beauty of redux itself is the lack of magic. It's essentially just a design pattern and is trivial to follow. So the "edit" part of your comment is key here: frameworks built on top of redux, including middlewares, store enhancers and stuff can definitely lead to an app that is hard to reason about with side effects happening in places you don't expect. IMO that ends up being the worse of both world: even with al…

Redux is difficult to reason about because side-effects can be triggered from anywhere in the application by middleware. If you're using something like redux-thunk, a single dispatch can cause both a store mutation AND trigger a side effect, which is confusing. I'd rather have those be 2 separate concerns. Those dispatches can be triggered from anywhere in the app, and multiple middlewares may trigger multiple side-e…

You should checkout https://github.com/jumpsuit/jumpstate

It's much easier to reason about, including side effects, while not being too magical.

Re: Redux-query – A React/Redux library for querying and managing network state

#53

If anyone's interested, I maintain a list of Redux-related addons and utilities over at https://github.com/markerikson/redux-ecosystem-links . Includes just about every vaguely-useful-looking middleware, action-generation utility, devtool, store enhancer, fill-in-category-here, that I've seen out there. (And yes, I already had redux-query in the list before this post :) )

I went to star this only to realise that I already had

Great work :)

Re: Redux-query – A React/Redux library for querying and managing network state

#54
Everyone says redux and react make for great component isolation.

How many of you people who use this combo can swap redux out at a whim, for another state management tool? How many of your components have been modified to work with the opinions of redux? Why do i need to couple my components with redux using connect()?

In my experience, redux and react on there own present decent patterns to simplify UI experience, but ive never seen a discussion that involves them that doesnt couple one with the other.

Re: Redux-query – A React/Redux library for querying and managing network state

#55

Earlier quoted context omitted.

Redux uses Event Sourcing. ES's trade-offs apply.

Its evented, not normally event-sourced. I don't know of many production uses of redux that also store the events for replay.

Addtionally;

Why apply your event to the state, then somehow sync your state with the server.

Wouldnt it be simplier just to sync your events?

Re: Redux-query – A React/Redux library for querying and managing network state

#56
post #54

Everyone says redux and react make for great component isolation. How many of you people who use this combo can swap redux out at a whim, for another state management tool? How many of your components have been modified to work with the opinions of redux? Why do i need to couple my components with redux using connect()? In my experience, redux and react on there own present decent patterns to simplify UI experience,…

There are two ways to make them more loosely coupled:

1. declare your connect's in a separate file that import your component and live alongside your containers, actions, reducers, etc.

2. write your own connect HOC that brings in redux. If you read the connect source[0] you'll find that it is actually really simple at it's core - but it is over complicated by having to account for so many use cases - your own HOC could/should be ~30 lines

I now use 2. because it produces proper separation and makes it easy to swap out components later on (or use more than one).

[0] https://github.com/reactjs/react-redux/blob/master/src/conne...

Re: Redux-query – A React/Redux library for querying and managing network state

#57

Earlier quoted context omitted.

Redux uses Event Sourcing. ES's trade-offs apply.

Its evented, not normally event-sourced. I don't know of many production uses of redux that also store the events for replay.

Redux in its essensce encourages half assed event sourcing.

Why do i need to memoise my state to stop the react render loop from happening? Isnt my event the source of truth? Its much more then a DTO.

Once your application becomes "event centric" instead of "state centric" you start to actually break free of the procedural paradgim and really become functional reactive.

Redux to me is DDD and ES for non-programmers. My domain logic is the gatekeeper to my state, and as such, should be coupled together. I dont combine my aggregates, just the same way i dont combineReducers. Code smell much.

Re: Redux-query – A React/Redux library for querying and managing network state

#58
post #2

I love react, with the reusable components and the ergonomic of jsx but I really don't like what redux does to your code: it involves too much magic, you lose the concept of independent components and every change becomes a global one: everybody is notified of the inner state of each component … To me it just break all encapsulation and just lead to massive tangled code that is really hard to maintain … Edit: I want…

this is the first time i've ever heard someone complain of redux having too much magic

most people complain there is too much boilerplate!

Re: Redux-query – A React/Redux library for querying and managing network state

#59
post #54

Everyone says redux and react make for great component isolation. How many of you people who use this combo can swap redux out at a whim, for another state management tool? How many of your components have been modified to work with the opinions of redux? Why do i need to couple my components with redux using connect()? In my experience, redux and react on there own present decent patterns to simplify UI experience,…

Swapping the management would be difficult, they all have their own patterns and implementations. But swapping Redux is absolutely possible. The logic sits in a self contained container which you can plug into literally every framework under the sun. The "connect" you're talking about is in place for React, Ember, Angular, Vue, Knockout, Mithril, Cycle, etc. Redux is also the closest you can get to a true universal app, because you can share it between code-bases (desktop app, web app, mobile app, backend even if you need).

We deploy a library based on this. It has reactive/changing datastructures that need to be presented visually. It runs on redux internally, and that is what makes it possible for our customers to embed it, no matter which framework they choose, even if it's JQuery. They form a simple dress and get served the properties and actions to display and excute. "Connect" makes their stuff aware of changes.

Re: Redux-query – A React/Redux library for querying and managing network state

#60
post #54

Everyone says redux and react make for great component isolation. How many of you people who use this combo can swap redux out at a whim, for another state management tool? How many of your components have been modified to work with the opinions of redux? Why do i need to couple my components with redux using connect()? In my experience, redux and react on there own present decent patterns to simplify UI experience,…

We try to keep our views and business logic reasonably well isolated. You see something in larger REST APIs, where the business logic is wrapped in a service object with is kept separate from everything else.

Recently we had a small "hackathon" event to evaluate GraphQL and Relay. Once the GraphQL server was up and running, getting Relay working with our app was really easy. Unfortunately, the migration path for adopting it heavily didn't seem to be worth it for us.

Post reply on HN