I haven't seen much mention of Apollo here. It offers a 'full stack' state management solution from server to client to offline cache. Each component can be adopted independently, but they work really nicely together. The tradeoff is that you're writing graphql, but it comes along with a lot of benefits, like consolidating requests etc. On the server-side, graphql can be a thin wrapper over rest apis. Defining good s…
Things I wish I knew about state management when I started writing React apps
321–330 of 335 posts
Re: Things I wish I knew about state management when I started writing React apps
#322Been using alt.js for ages and continued to make use of it in React, never really ran into the issues described. Use it as a store or cache that alerts all your components of data changes, works well enough.
Re: Things I wish I knew about state management when I started writing React apps
#323Earlier quoted context omitted.
Ok; ignore that specific example -- if you needed to share a piece of state among many components in different places in your component tree, how would you do it?
I have 3 tiers of components. Root - Page/Screen - UI Elements The Root takes care of authorization and navigation logic, to switch between pages. A Page has all the logic needed for one page it holds all the state and passes it down via props. A UI Element displays the state it got via props and sends up its events via handler function (it also gets them via props) In 90% if cases this was enough. Sometimes, I neede…
Re: Things I wish I knew about state management when I started writing React apps
#324Earlier quoted context omitted.
> e.g. having the “NavigationService” change which links should be available by listening to a state change on the “UserSession” service as a user becomes authenticated. Could you expand on how you're achieving this? I'm creating a new project using xState at work and this is one of the things I've been trying to come up with a solution too. My biggest problem is the pattern I've set up for routing on top of xState (…
We keep things very simple. Maybe that will have to change as the code base grows, but for now it works and it easy to grok. On start of the application we create singletons of our state machine backed services, and manage the dependencies between them manually. That is, we create an instance of the UserSessionService and then pass it into a "constructor" for the NavService. That constructing function creates the Nav…
I'll have a think about this and see if I can work it into my structure as I'm certainly going to need inter-machine communication as it grows.
The `makeMachineRoutable` function in this gist is what I'm using to consume my state machines in React. https://gist.github.com/UberMouse/49ff91e95390265d63d3ac1bc7...
It also shows my prototype for xstate based declarative data fetching, though I have sinced switched to using observables instead of promises for representing my GraphQL query results so I've changed it quite a bit.
Re: Things I wish I knew about state management when I started writing React apps
#325Earlier quoted context omitted.
"is React simpler for building UIs than the RAD tooling of Visual Basic, Delphi or the Flash Designer" I asked something like this too, but the other way around. "If Flash, Delphi, etc. were so good, where are they now?" The answers were: These tools were good for one developer or small teams, but textual dev tools scaled better to big teams.
Delphi and it's opensource cousin Lazarus/Freepascal are doing just fine and I use those to implement desktop applications. Single exe with no dependencies. Beauty. Sure they're not popular in North America but I could care less. Those tools save me a boatload of time. There is also QT. "The answers were: These tools were good for one developer or small teams, but textual dev tools scaled better to big teams." Utter…
Re: Things I wish I knew about state management when I started writing React apps
#326Earlier quoted context omitted.
Delphi and it's opensource cousin Lazarus/Freepascal are doing just fine and I use those to implement desktop applications. Single exe with no dependencies. Beauty. Sure they're not popular in North America but I could care less. Those tools save me a boatload of time. There is also QT. "The answers were: These tools were good for one developer or small teams, but textual dev tools scaled better to big teams." Utter…
How big is your team?
Re: Things I wish I knew about state management when I started writing React apps
#327Earlier quoted context omitted.
How big is your team?
Wrong approach. The claim was made that Delphi does not scale for big teams. Name me one single Delphi related (mis)-feature that prevents it to scale.
Checking if the users are all small teams would at least imply that this could be true.
Re: Things I wish I knew about state management when I started writing React apps
#328Earlier quoted context omitted.
> The ~100ms between submitting a form and getting error messages isn't that big of a hurdle, in my experience Sure, it's the >100ms between the user entering the first value that might have an error and the user submitting the form that's a much bigger problem between validate-on-server-on-submit and validate-on-client-on-entry. > But I don't agree React _benefits_ developer productivity. On the contrary, I think it…
I've been professionally working on SPAs for the past 7 years. I'm familiar. I strongly disagree with the premise that it's in any way more productive. I'm, at a minimum, 2x more productive building something the traditional "Rails way" with server-rendered HTML, and a handful of JS enhancements where necessary vs doing a full-blown SPA. I'd love to do a showdown, and challenge anyone to a head-to-head non-trivial ap…
Not every organization can use this approach either. E.g. I work at a True Java Shop(tm), where voicing the idea of using Ruby for a back end service would get me laughed out of the room with a permanent label of That Funny Guy Who Likes Toy Languages.
Using React for a front end client application that consumes back end API built in Java is 10x more productive than doing the traditional "Java Way" application with server-rendered HTML.
Re: Things I wish I knew about state management when I started writing React apps
#329Earlier quoted context omitted.
> The ~100ms between submitting a form and getting error messages isn't that big of a hurdle, in my experience. The issue here is not the length of time it takes for the response to come back, rather the fact that there is any delay at all. Client side validation code can be synchronous, submitting any validation info to the server makes it asynchronous by definition. State synchronization between client and server i…
> It can be argued that I did not use the best server side framework, did not know what I was doing, etc. That's actually my point: if doing old style web apps was so much easier, I should have been able to complete it fast without much sweat, no? Having seen many similar discussions I came to the conclusion this might really be something of a generation gap. For those of us who spent their youth developing web apps…
No thanks, not gonna do that ever again. Rosy glasses are rosy, and cleanly separated client side app + back end API is clean and separated.
Re: Things I wish I knew about state management when I started writing React apps
#330Earlier quoted context omitted.
I just thought of another critical difference when using "Qt, etc". These toolkits all have at their heart an event loop that looks something like: while (!should_quit()) { wait_for_user_input_or_other_events(); process_events(); // may mark some components for redraw redraw_anything_that_needs_it(); } So if user input or some data source indicates that some on-screen component now needs to be red with a yellow borde…
It is pretty much the same, except there is no explicit loop and calls to wait for events written in JS/React code. Javascript itself runs a loop, instead of polling for events, you define events handlers, and DOM/React handles "redraw anything that needs it" part.
Gtk::Main app;
...
app.run ();