XState - Data Loading Service - Finite State Machines in React

  Рет қаралды 11,170

Leigh Halliday

Leigh Halliday

Күн бұрын

Пікірлер
@MathieuGosbee
@MathieuGosbee 5 жыл бұрын
Day 2 on learning XState, and this has helped me immensely, and something has clicked. I can now do relatively simple things using state machines!
@leighhalliday
@leighhalliday 5 жыл бұрын
Nice! Thanks for sharing, Matbee :)
@sourenasahraian2055
@sourenasahraian2055 2 жыл бұрын
Great intro , much obliged !
@JaeTask
@JaeTask 4 жыл бұрын
Really helpful thanks. I watched a tonne of david's xstate presentation but he tends to focus on what it can do instead of how we do it. Something just clicked :) nice one
@leighhalliday
@leighhalliday 4 жыл бұрын
Thank you very much Jae! Xstate was pretty hard for me to wrap my head around but provides a ton of functionality.
@migueldomingos4570
@migueldomingos4570 4 жыл бұрын
Amazing video as always;-) But i just want to say that the Machine function doesnt need new.
@leighhalliday
@leighhalliday 4 жыл бұрын
Thank you Miguel!!
@migueldomingos4570
@migueldomingos4570 4 жыл бұрын
@@leighhalliday You are welcome
@stevereid636
@stevereid636 5 жыл бұрын
Awesome! Thanks ever so much for this.
@leighhalliday
@leighhalliday 5 жыл бұрын
Thanks for watching, Steve!
@vdev6797
@vdev6797 5 жыл бұрын
Please make more videos on Xstate + React + Redux ...!!! Pleaseeee :-))
@leighhalliday
@leighhalliday 5 жыл бұрын
I'll do my best! I don't use redux much, but I aim to keep making videos :)
@g-luu
@g-luu 4 жыл бұрын
@@leighhalliday Hi Leigh i might be confused but doesn't xstate replace redux in this case?
@migueldomingos4570
@migueldomingos4570 4 жыл бұрын
@@g-luu it does
@kirankothandan5529
@kirankothandan5529 4 жыл бұрын
Awesome
@leighhalliday
@leighhalliday 4 жыл бұрын
Thanks Kiran!
@petrpacas
@petrpacas 4 жыл бұрын
Nice presentation, thanks 💪
@leighhalliday
@leighhalliday 4 жыл бұрын
Thanks, Pakas, glad you enjoyed it!
@les2997
@les2997 5 жыл бұрын
If you could cover in a future video more advanced topics such as actors, this would be much appreciated.
@leighhalliday
@leighhalliday 5 жыл бұрын
Hey Les! Thanks for the suggestion.
@migueldomingos4570
@migueldomingos4570 4 жыл бұрын
I hope that you dont mind(if you do please notify me so i can take action) that i made two codepens based of these tutorials.
@leighhalliday
@leighhalliday 4 жыл бұрын
Thank you Miguel, I don't mind at all!
@migueldomingos4570
@migueldomingos4570 4 жыл бұрын
@@leighhalliday Thanks bro
@louis345
@louis345 4 жыл бұрын
Could you do a video for login form?
@leighhalliday
@leighhalliday 4 жыл бұрын
Already done my friend! Auth in Next.js: kzbin.info/www/bejne/aaKXc6d5r9qlr7s User Registration Form: kzbin.info/www/bejne/o6O3gaWYiNR0rpI
@romanmunar
@romanmunar 4 жыл бұрын
Hey leigh, I've been tinkering with xstate lately, my quick questions is, what state would you put in a machine and what you dont. For me, putting all state in machines is entirely feasible, and I haven't ran into issues yet.
@leighhalliday
@leighhalliday 4 жыл бұрын
Hey Roman! I think it works best for things that have "finite" states... loading an HTTP request is: initial, loading, completed, error... and only certain transitions between those states make sense. You can't go from completed to error, as they are both "end" states. You can't arrive at "completed" without first going through "loading".
@romanmunar
@romanmunar 4 жыл бұрын
@@leighhalliday I see, I am using it as how you would with a context api. I should think of it more as sequence of events. interesting, it's as if states have predefined reducers on their own. This is tough, this requires extensive planning before diving in. Also, There is this new library from react-spring called jolai, a mini recoil-like state manager if possible, do check it out.
@wateva9000
@wateva9000 4 жыл бұрын
A cool video, but I dont see that this usecase actually needs a statemachine. I mean what you did I achieved with much less lines. Definitely cool for experimenting with it, but still struggling to find the actual usecase for it. Perhaps some UI state changes for like drag n drops etc..Or some forms that are tighly coupled in the ux. let fooState = success; let page = 1; const fooStates = [success, loading, error] async loadFoo() try { fooState = loading await load( { page }); page +=1; fooState = success } catch { fooState = error }
@leighhalliday
@leighhalliday 4 жыл бұрын
Fair enough! I often make these videos just to learn a library myself :) The point isn't to say "you have to use this in this use-case" but to introduce concepts... maybe it doesn't fit here, but it'll be useful elsewhere! Being transparent, I haven't used xState much in the real world, but I can see how it is useful to define a finite list of states and the rules and events which would cause it to transition from one state to the next. For example, it doesn't make sense to go from "success" to "error" without passing through the "loading" state... by defining the state chart with xState, especially with their visualizer (xstate.js.org/viz/) it becomes much clearer, allowing you to define rules. But yea, it's a lot of boiler plate and code, no?
@wateva9000
@wateva9000 4 жыл бұрын
@@leighhalliday Yea.. don't get me wrong is a good tutorial and I did create the chart myself as well following the video. Just having problems myself to find a realworld usecase :D Would be super cool do find a real one and then put it on a pull-request :D
@migueldomingos4570
@migueldomingos4570 4 жыл бұрын
@@wateva9000 For simple state it doesnt make sense but for more complex state it is amazing! It is a joy! You define exacly what can happen and when. No more ui bugs! But yeah i wouldnt recommend it to do simple stuff like opening a dropdown
@migueldomingos4570
@migueldomingos4570 4 жыл бұрын
@@morpheuspk94 He explains it in thsi video: kzbin.info/www/bejne/fKvPpqWwqKiKaq8
Goodbye, useEffect: David Khourshid
26:01
Real World React
Рет қаралды 235 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
David Khourshid - Infinitely Better UIs with Finite Automata
25:33
Finite State Machines in JavaScript
14:19
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 14 М.
XState - An introduction - Finite State Machines in React
8:06
Leigh Halliday
Рет қаралды 14 М.
Introduction to XState
25:29
Jon Bellah
Рет қаралды 37 М.
The Genius Way Computers Multiply Big Numbers
22:04
PurpleMind
Рет қаралды 185 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН