There are many ways to represent state in modern web applications. In Vue, you can use local state, encapsulated within components, or global state, using a state management library like Vuex. It usually works the same way: you represent it with properties that you can change, and you use these properties to determine view logic.
State changes are imperative most of the time: you set up event listeners to update reactive properties, and condition them with if statements. As the application grows, this quickly turns into a tangled mess: new conditions, new events, new corner cases. Before you know it, you end up with contradictory instructions that set your view in an inconsistent state. This is what state machines attempt at solving. Finite state machines let you represent the behavior of a system that can be in only one state at any given time. There’s a finite number of possible states, triggered by a limited number of possible events. Instead of defining imperative UI flows and losing track of their logic, state machines make state changes first-class citizens by letting you model them declaratively.
We’ll see how state machines wonderfully fit into Vue’s reactive model. We’ll live code a non-trivial project that leverages state machines with the Composition API, and see how it results in readable, declarative, reliable code that’s easy to reason with.
1 view
1129
310
11 months ago 00:23:54 1
Машина Состояний Telegram Бота | Finite State Machine Python Aiogram
11 months ago 00:15:02 1
The First Spinjitzu Master (FSM) & his Wife react to Lloyd, Garmadon & Wu (Ninjago Gacha react)
11 months ago 00:05:12 1
Nightwalker by FSM Team feat. e s c p [ Cinematic / Ambient / Chill-Out ] |
11 months ago 02:19:50 1
Капкан для Китая: Россия и Иран должны пасть? Шахматная партия англосаксов. Шабанов, Арестович
12 months ago 00:03:54 1
Shai Linne - Elder Statesman
12 months ago 02:00:30 1
About the Spiritual World
12 months ago 00:03:32 3
My Very Favorite Hymn | Beautiful Worship Song “He Flies“ | Church of FSM
12 months ago 00:02:26 55
RED MEDAL FOR 2 MONTHS | КРАСНАЯ МЕДАЛЬ ЗА 2 МЕСЯЦА | GXP | FSM BOOST | CS:GO XP BOOST | FSM TOOL
1 year ago 00:18:56 2
How to Program in Unity: State Machines Explained
1 year ago 00:06:03 1
FLESHGOD APOCALYPSE - The Day We’ll Be Gone (Acoustic) (OFFICIAL MUSIC VIDEO)