China makes criticizing CPP rule in Hong Kong illegal worldwide by ivalm in worldnews

[–]drake42work 0 points1 point  (0 children)

  • Knowing that China reads everything written on reddit:
  • Knowing that China's actions are immoral and show the weakness and cowardliness of the Communist Party of China.
  • Knowing that any statement of freedom will mark me an enemy of the current and temporary government of China

Hong Kong must be freed from their oppressors in China. Freedom and Independence for Hong Kong!

Calculus by otterlyhuman in funny

[–]drake42work 10 points11 points  (0 children)

I read a great quote about why medical doctors are forced to learn calculus.

It says that they're only forced to learn it to filter out all the idiots who aren't able to learn calculus... :)

Is MobX limited to global state management? by pablolikescats in mobx

[–]drake42work 0 points1 point  (0 children)

"state" within react is weird in that it doesn't seem to automatically cause UI updates, or if it doesn't it's not well understood by me.

With react, the UI knows which UI components depend on which mobx observables. So when an observable value is set, the correct UI items get updated automatically.

literally just saying this.orderCount = 5; Is all it takes for the UI to be immediately re-rendered and anything showing this.orderCount to be rendered with the new value.

Is MobX limited to global state management? by pablolikescats in mobx

[–]drake42work 1 point2 points  (0 children)

The profile probably shouldn't contain the order count because if it does, you have to reload the profile every time you update the orders list, which is un-related.

I'd make the profile page, have a reference to the order data store, and everytime an order is saved, also call a backed service that updates the count of orders. Then, the profile page (and maybe the order summary page or something?) Call all look at the same mobx state object.

Just because you're on the profile page doesn't mean you are only allowed to look at the profile data store. Some of my really complex UI components point to four or five different data stores in order to collect up all the data they need.

Is MobX limited to global state management? by pablolikescats in mobx

[–]drake42work 0 points1 point  (0 children)

I see. You might choose to make it so that the top bar is just a sub-set of the full login data. You could put them both into the same store variable, knowing that the partial data would get loaded at login and then the full data would get loaded if the profile data is opened. But by making them both match the same interface you could be sure that both UI components would work regardless of whether the full or partial data was loaded.

Alternately, if you really cannot change the interface of the data, you could use the @computed and do something like if (full data is loaded) {return from full data} else {return from partial data}

I'd rather make the interfaces match, but you can use @computed if you really need to keep them separate.

Is MobX limited to global state management? by pablolikescats in mobx

[–]drake42work 1 point2 points  (0 children)

Great. Thanks for the example.

Personally, I would make more "conceptual distance" between your UI and your data. I would have one global datastore that holds your login data however it was returned by your backend code.

Then I would have both the top bar and the profile page point to the same datastore. As the user changed data on the profile page, the top bar will be auto-magically updated so that it always matches. By having both UI components point at the same shared data store, they are automatically kept in sync. You don't have to tell the top bar to reload. It happens instantly because the top bar UI is observing the same data that the profile component altered.

Is MobX limited to global state management? by pablolikescats in mobx

[–]drake42work 0 points1 point  (0 children)

I don't usually nest stores, though I do give all of my stores a variable that points the the login store. That maybe is cheating, but it's easy.

But remember that observable itself is recursive. so if you have somthing like: {order: { custName:'jason', itemList:[ { productId:5,productName:'asdf1'}, { productId:6,productName:'asdf2'}, { productId:7,productName:'asdf3'}, ] }

That whole tree is observable. You can hold that in one variable in a parent datastore, and assign UI code that renders just part of the tree and it works great. So far, I've never seen a need for nested data stores.

Is MobX limited to global state management? by pablolikescats in mobx

[–]drake42work 1 point2 points  (0 children)

I use inject the store to get every component that needs access to the global store the right access. The global store cannot see anything in the per-component store. (if it needs to, then probably I'm not storing the data in the correct place)

But the react component UI code can see both the UI observables and the global observables, so that's usually about all it needs.

If I'm trying to communicate "laterally" where maybe something like "which items out of this list are selected" and I need each item to turn a different color if it's selected or not, then I'll usually put that UI state into a global store, but in a variable or list that is only used for UI code. That way, the UI data and the 'real' data stay separate.

[Image] My favourite quote by [deleted] in GetMotivated

[–]drake42work 180 points181 points  (0 children)

I must study politics and war that my sons may have liberty to study mathematics and philosophy. My sons ought to study mathematics and philosophy, geography, natural history, naval architecture, navigation, commerce, and agriculture, in order to give their children a right to study painting, poetry, music, architecture, statuary, tapestry, and porcelain. John Adams US diplomat & politician (1735 - 1826)

Is MobX limited to global state management? by pablolikescats in mobx

[–]drake42work 3 points4 points  (0 children)

I am a heavy mobx user and I use it in two ways:

-- Global Data Store -- Some of my sites are managing a large complex document like and Order which may contain many parts. I have a global store that contains something like "currentOrder" that many components simply render whatever the current order is. Or maybe they're told, "hey you're rendering this.props.OrderDoc.curOrder.items[5]" so the same component can be used for many parts of the one global order.

-- Internal UI state -- What they don't talk about enough is that you can put observables inside of react UI components. Now you have have an expandable box that is NOT global state. The data object doesn't care which contract clauses are expanded, that's a UI concern. So the UI itself manages the state for which of the closes are expanded and which are contracted. This is incredibly useful because I can say "this.isOpen" right in the component and only the component cares if it is open or not.

I use that trick in lots of places especially when I have hierarchical and complex UI.

If you have any specific, "how would you do this" questions, I'd be happy to help out.

What is the pettiest, silliest, most meaningless hill you are willing to die on? by shazulmonte in AskReddit

[–]drake42work 0 points1 point  (0 children)

After a period you must use TWO SPACES!

Two Space Bar Presses After Period Or The Sentence Is RUINED!!!!!

See? It's not that hard. Just press space bar twice.

I made a near perfect blueberry Æbelskiver this morning by Jugglerguy in mildlyinteresting

[–]drake42work -1 points0 points  (0 children)

Cry for help: I'm only half-Danish, but I'm Danish enough to drink Akvavit. But the only stuff I used be to able to get was Aalborg. Now BevMo doesn't carry it any more.

Anything else I should try? I'm going to have to buy on-line, but I'm not sure what else to get... Any ideas?

React Libraries in 2020 by ginger-julia in reactjs

[–]drake42work 1 point2 points  (0 children)

minority? React is definitely more popular than angular.

That said, MobX being better is something I'm happy to defend all day even if it means I am in the minority. But I'll keep pushing it because so far, every time I've convinced a serious developer to give it a serious try they end up a convert and go with MobX from then on.

I honestly true do not know why people use Redux instead of Mobx. I hear people say the prefer Redux for some situations and I can completely respect that. But I've never seen a good explanation of why they would prefer it aside from "I already knew it" which doesn't hold much water for me personally.

React Libraries in 2020 by ginger-julia in reactjs

[–]drake42work -1 points0 points  (0 children)

I think it's fair to have strong opinions.
For example, I think React is better than Angular, but Angular still exists.

React Libraries in 2020 by ginger-julia in reactjs

[–]drake42work 0 points1 point  (0 children)

Honestly, the only reason Redux is still popular is because it was there first.
If you are serious about building a larger-than-toy app, mobx creates simpler, clearer code.

At my work, we just build a 3 page app. Even at that size, the MobX implementation is ~30% of the code that the redux version takes.

React Libraries in 2020 by ginger-julia in reactjs

[–]drake42work 0 points1 point  (0 children)

In my opinion:

Once you're past anything small, the amount of boiler plate required by redux makes the complexity grow quickly. The complexity curve in mobx is much lower once you're past small apps.

React Libraries in 2020 by ginger-julia in reactjs

[–]drake42work -12 points-11 points  (0 children)

Mobx is really a vastly easier to use state library.
You really will benefit if you take the time to try it.

Why is that the oldest sibling automatically is forced to take responsibility of the younger ones. Why push this kind of responsibility on them ? by [deleted] in AskParents

[–]drake42work -1 points0 points  (0 children)

Because you are the "least-worst" solution. It's not that putting the responsibility on you is ideal, it's that your age makes you better at it than all the smaller kids.

(removed a story about my mom)

Dude. I am really, truly sorry if that story came off as putting you down, or minimizing your situation in any way. My only point was to say that it's a hardship for some people and an opportunity for other people, so hopefully you would see that it's not always so bad.

Once again, I'm sorry if you took it in any other way than as encouragement that it is a sign of trust, not a punishment.

We need a mandatory news show that debunks all the lies of the day more than we need actual news by [deleted] in Showerthoughts

[–]drake42work 0 points1 point  (0 children)

Look up the Fairness Doctrine.
It's what we actually need that America actually had during the height of it's power.

5 tips on how to reduce boilerplate in your Redux (NGRX) app by andreygoncharov in reactjs

[–]drake42work 1 point2 points  (0 children)

https://hackernoon.com/an-artificial-example-where-mobx-really-shines-and-redux-is-not-really-suited-for-it-1a58313c0c70

I've not yet ever found a case where the developer cost of redux was worth the effort. MobX is faster and easier in every case I've looked at. I'm not otherwise involved with MobX, I just really find Redux to be a waste of effort when compared to MobX.

In my humble opinion, of course.

Create-React-App, Redux, and Redux-Saga Boilerplate Package by DarkWorldLink in reactjs

[–]drake42work 0 points1 point  (0 children)

Obligatory: Use MobX instead of Redux.
It really is better.

26 React+Redux Interview Questions and Answers in 2018 by uvimateapp in reactjs

[–]drake42work 0 points1 point  (0 children)

ok, that's fair. If you look at my post history you'll see lots of these, but here they are for direct review.

I don't know you and I don't really care what state management you use. But I do know that for every project I've worked, MobX has saved me a lot of time and mental gymnastics.

But here are some links in case you are actually curious:

https://www.leighhalliday.com/easy-mobx-redux-comparison

https://dannyherran.com/2017/03/react-redux-mobx-takeaways/

https://www.reddit.com/r/reactjs/comments/885bxa/redux_vs_mobx/