Live data from Hacker News

Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

github.com

21–30 of 42 posts

Re: Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

#21
post #2

Slightly off topic, but how do people manage state that aren't using Redux? When you google "redux alternatives", you typically get results for different flavors or variants of redux. But are there other fundamentally different paradigms for managing state? I love Redux, but I'm really curious what else is out. Also, the optimistic updates with rollbacks in this implementation is pretty neat.

Since we have been using graphql and apollo-client i personally havent had a moment where we really missed redux[1]

[1]: technically apollo client uses redux internally but they keep it nicely wrapped for you

Re: Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

#22
post #2

Slightly off topic, but how do people manage state that aren't using Redux? When you google "redux alternatives", you typically get results for different flavors or variants of redux. But are there other fundamentally different paradigms for managing state? I love Redux, but I'm really curious what else is out. Also, the optimistic updates with rollbacks in this implementation is pretty neat.

I've been using Mobx very successfully on many of my projects now (both React & React Native). I'll prefer Mobx any day over Redux, just due to it's sheer simplicity and ease of use. Read: No need to burden your brain with the cognitive load of actions, reducers, dispatching actions, selectors etc. Mobx v/s Redux does kick off the OOP v/s Functional debate, but as a developer my productivity and effectiveness is meas…

Maintainer of Redux here.

I concur with giving Mobx a try. I'm using it at least one product so far and it's been working out great.

One thing I will say is that because your subscriptions are set up implicitly, it's easy to have things misbehave in unexpected ways. For instance, if you update multiple observable properties in a single function, it will fire off observers multiple times. That could put you into an unexpected state and cause some errors.

Luckily, almost every time I've run into this kind of issue, I've discovered there's an API to cover that case (runInAction in the previous example's case). And they APIs themselves are really neat and fun to work with. `when` and `observable.array`'s extensions are some of my favorites.

Re: Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

#23
post #2

Slightly off topic, but how do people manage state that aren't using Redux? When you google "redux alternatives", you typically get results for different flavors or variants of redux. But are there other fundamentally different paradigms for managing state? I love Redux, but I'm really curious what else is out. Also, the optimistic updates with rollbacks in this implementation is pretty neat.

MobX is quite popular, and I wouldn't call it a variant of redux. Also, just storing state in your higher level components can work for much more complicated apps than many think.

This is so true. Just apply the Redux idea of smart/dumb components but without actually using Redux. Higher level component(s) becomes smart and handles the state changes while passing down only properties to children.

Usually I start an app like this and when things get really complicated I add Redux and refactor the state management out of my top component.

MobX looks interesting, however didn't get to try it out yet, only briefly looked over it. I find it a bit annoying that they introduce even more syntax overloading - annotations - as if ES6/7/JSX is not enough already. Will give it a try on a pet project soon.

Re: Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

#24
Please note: This is certainly a very helpful library, but it's made to work with some kind of server/API. The defaults assume you get a connection again within one hour. Obviously, you can tweak the defaults.

But if you want to build an app with its own real functionality that has sync added (like a TODO list that syncs with other devices) and is entirely offline-first where you can go weeks without a connection, you better keep searching. Maybe have a look at PouchDB.

Re: Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

#25
post #7

I'm re-learning Redux now, does anyone else think that it might be overkill for an app that doesn't require any user input?

Yes. Redux's advantages are only relevant if you have a lot of changing/updating data, which usually comes from user input. My personal litmus test is if the Redux devtools (https://github.com/gaearon/redux-devtools) sound like a must-have feature.

Re: Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

#26
post #2

Slightly off topic, but how do people manage state that aren't using Redux? When you google "redux alternatives", you typically get results for different flavors or variants of redux. But are there other fundamentally different paradigms for managing state? I love Redux, but I'm really curious what else is out. Also, the optimistic updates with rollbacks in this implementation is pretty neat.

I've been using Mobx very successfully on many of my projects now (both React & React Native). I'll prefer Mobx any day over Redux, just due to it's sheer simplicity and ease of use. Read: No need to burden your brain with the cognitive load of actions, reducers, dispatching actions, selectors etc. Mobx v/s Redux does kick off the OOP v/s Functional debate, but as a developer my productivity and effectiveness is meas…

Do you pass the MobX stores down to every child component as props or do you use @inject? I started with the former but all of a sudden all my components had all these "default" props that cluttered things up. @inject seems great but the documentation doesn't push it enough to make me believe it's best practice.

Re: Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

#27
post #24

Please note: This is certainly a very helpful library, but it's made to work with some kind of server/API. The defaults assume you get a connection again within one hour. Obviously, you can tweak the defaults. But if you want to build an app with its own real functionality that has sync added (like a TODO list that syncs with other devices) and is entirely offline-first where you can go weeks without a connection, yo…

Other than Couch/Pouch, are there any other projects providing solutions to this problem? The one thing I dislike about couchdb is the default "user-per-db" model.

I'm interested in solutions that allow a traditional relational db instead of a key-value store. Seems like with indexeddb on the client, and postgres on the server, you could probably keep a segment synced.

Re: Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

#28
post #26

Earlier quoted context omitted.

I've been using Mobx very successfully on many of my projects now (both React & React Native). I'll prefer Mobx any day over Redux, just due to it's sheer simplicity and ease of use. Read: No need to burden your brain with the cognitive load of actions, reducers, dispatching actions, selectors etc. Mobx v/s Redux does kick off the OOP v/s Functional debate, but as a developer my productivity and effectiveness is meas…

Do you pass the MobX stores down to every child component as props or do you use @inject? I started with the former but all of a sudden all my components had all these "default" props that cluttered things up. @inject seems great but the documentation doesn't push it enough to make me believe it's best practice.

Neither. Just import a singleton root store and reference it directly.

Re: Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

#29
post #2

Slightly off topic, but how do people manage state that aren't using Redux? When you google "redux alternatives", you typically get results for different flavors or variants of redux. But are there other fundamentally different paradigms for managing state? I love Redux, but I'm really curious what else is out. Also, the optimistic updates with rollbacks in this implementation is pretty neat.

I just came across Vue.js the other day, while exploring options for quickly banging out small tools. Getting tired of the clutter in a full-featured React project.

It offers more than one strategy for managing state; there is simple two way binding between a JS object and the DOM, there is the Elm-inspired vuex, and also it can integrate with Redux. http://vuejs.org/v2/guide/state-management.html

Re: Show HN: Redux Offline – Build Offline-First Apps for Web and React Native

#30

Earlier quoted context omitted.

MobX is quite popular, and I wouldn't call it a variant of redux. Also, just storing state in your higher level components can work for much more complicated apps than many think.

This is so true. Just apply the Redux idea of smart/dumb components but without actually using Redux. Higher level component(s) becomes smart and handles the state changes while passing down only properties to children. Usually I start an app like this and when things get really complicated I add Redux and refactor the state management out of my top component. MobX looks interesting, however didn't get to try it out…

To be fair they give many examples of using mobx without decorators. I use them because they're baked into typescript, but I wouldn't use the Babel plugin, it seems less mature.
Post reply on HN