XState in React Native - How I finally managed to keep my views lean and my logic clean - March 2023

Опубликовано: 27 Октябрь 2024
на канале: Pusher
1,440
32

Dario Villanueva: XState in React Native - How I finally managed to keep my views lean and my logic clean

React Native London - March 2023

Are you tired of messy states, putting all your business logic in your views or a having a redux reducer more bloated than Sam Smith’s dress at the Brit awards this year? Well fear no more. Meet Finite state machines, something you probably learnt in first year uni and that has helped us in innumerable ways, from defeating the nazis and building parking meters, to animating your favourite video game characters.

In this talk, I’ll show you how you can model complex business logic (or a cat) for your react native apps in a way that’s deterministic, testable, and easily maintainable.

[00:00:00] Intro
[00:00:28] About me
[00:00:44] What we'll cover
[00:02:19] What does a Fortnight character and Parking Meter have in common?
[00:03:03] What is a Finite State Machine?
[00:04:40] About XState
[00:06:08] Modelling a cat with XState
[00:07:41] Anatomy of a Cat Machine
[00:08:18] States, events and transitions
[00:09:18] States can be "nested" - (child states)
[00:09:58] Actions for side effects
[00:10:32] Machine Context
[00:11:16] Services (soon to be renamed Actors)
[00:13:21] Guards - for conditional Transitions
[00:13:46] Docs available
[00:14:22] Integrating with React Native
[00:15:12] Add a navigator
[00:16:32] Use a hook to navigate by subscribing to state
[00:19:29] Things to remember
[00:23:31] Why do XState
[00:26:48] Why don't I just use redux?
[00:28:33] FSM
[00:30:13] References
[00:30:46] Q&A

_________________________________________________________________

About Pusher Sessions:

We're bringing the meetup to you. With Sessions, you can watch recordings of top-notch talks from developer meetups -- wherever and whenever you want.

Meetups are a great way to learn from our peers and to keep up with the latest trends and technologies. As developers ourselves, we at Pusher wanted to bring this great content to more people... So we built Sessions. On Sessions, you can watch talks that interest you and subscribe to be notified when new content gets added.

If you run a meetup and want to get involved, kindly get in touch.

_________________________________________________________________

About Pusher:

Pusher is a hosted service with APIs, developer tools and open source libraries that greatly simplify integrating real-time functionality into web and mobile applications.

Pusher will automatically scale when required, removing all the pain of setting up and maintaining a secure, real-time infrastructure.

Pusher is already trusted to do so by thousands of developers and companies like GitHub, MailChimp, the Financial Times, Buffer and many more.

Getting started takes just a few seconds: simply go to pusher.com and create a free account. Happy hacking!