Skip to content

Commit 21ca285

Browse files
committed
Apply formatting to all files
1 parent 3d83896 commit 21ca285

File tree

187 files changed

+1387
-1263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+1387
-1263
lines changed

blog/2023-1-27-making-state-machines-global-in-react/index.mdx

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ function SomeComponent() {
5959
return (
6060
<div>
6161
<p>Count: {count}</p>
62-
<button onClick={() => actorRef.send({ type: 'INCREMENT' })}>Increment</button>
62+
<button onClick={() => actorRef.send({ type: 'INCREMENT' })}>
63+
Increment
64+
</button>
6365
</div>
6466
);
6567
}

blog/2023-11-23-stately-studio-2-0-changelog/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ This is an excellent time to mention that annotations are now called notes! Note
6666

6767
In the machine’s bottom bar, you can now find undo/redo, zoom options and the help button on the bottom right. And managing machine versions, including switching and creating new versions, can now be done from the bottom left. While viewing a version, the buttons for restoring or duplicating the machine are still in the top bar.
6868

69-
When you import code into the editor without a project, We’ll now automatically create a new project for you.
69+
When you import code into the editor without a project, We’ll now automatically create a new project for you.

blog/2023-11-28-koordinates-and-stately-case-study/index.mdx

+22-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
title: 'Koordinates x Stately: geospatial data management case study'
33
description: Making geographic information systems accessible and collaborative. A Stately and Koordinates case study.
44
authors: [gavin]
5-
tags: [case study, study, koordinates, stately, state machines, machines, gis, geospatial]
5+
tags:
6+
[
7+
case study,
8+
study,
9+
koordinates,
10+
stately,
11+
state machines,
12+
machines,
13+
gis,
14+
geospatial,
15+
]
616
date: 2023-11-28
717
slug: 2023-11-28-koordinates-and-stately-case-study
818
image: /blog/2023-11-28-koordinates-and-stately-case-study.png
@@ -11,16 +21,15 @@ image: /blog/2023-11-28-koordinates-and-stately-case-study.png
1121
When it came to navigating the complexities of business context and application state, Koordinates found their solution in Stately's tools, reshaping their coding practices and ensuring a seamless user experience.
1222
{/* truncate */}
1323

14-
15-
1624
For more than 15 years, the team at [Koordinates](https://koordinates.com/) has been hard at work reimagining and building streamlined and equitable ways for customers to manage geospatial data. Koordinates have built a massively scaled GIS (Geographic Information Systems) platform for users to upload their own data, query over 18,000 open datasets, and securely merge openly available data with proprietary information.
1725
Unlike competing products that require vendor lock-in and lack compatibility across the entire GIS stack, Koordinates’ offerings are modular: users may use as much or as little of the tooling as they like, and the tooling is interoperable with existing GIS environments.
1826

1927
<p>
2028
<ThemedImage
2129
alt="Koordinates logo"
2230
sources={{
23-
light: '/blog/2023-11-28-koordinates-and-stately-case-study/koordinates_logo_black.png',
31+
light:
32+
'/blog/2023-11-28-koordinates-and-stately-case-study/koordinates_logo_black.png',
2433
dark: '/blog/2023-11-28-koordinates-and-stately-case-study/koordinates_logo_white.png',
2534
}}
2635
/>
@@ -48,36 +57,36 @@ In the case of Kart, many of these operations can be long-running and have sever
4857

4958
## Breaking complex UI’s into manageable components
5059

51-
In the case of both their products, Koordinates was able to use Stately’s tooling to break their “big” problems down into several, distinct smaller ones. Taylor Lodge, an engineer on the core team, explained that with Sta tely’s visual editor and simulation tooling, they were able to break their application logic into several small, testable state machines. For example, the UI for Koordinates Cloud has several components, but the logic for loading elements in their list view is represented rather succinctly in this state machine:
52-
60+
In the case of both their products, Koordinates was able to use Stately’s tooling to break their “big” problems down into several, distinct smaller ones. Taylor Lodge, an engineer on the core team, explained that with Sta tely’s visual editor and simulation tooling, they were able to break their application logic into several small, testable state machines. For example, the UI for Koordinates Cloud has several components, but the logic for loading elements in their list view is represented rather succinctly in this state machine:
5361

5462
<EmbedMachine
5563
name="Koordinates List View Machine"
56-
embedURL="https://stately.ai/registry/editor/embed/1b48bbf1-6f7a-4847-b1e0-47ee5c283371?machineId=68b835cc-49fc-4b9c-972e-a63c01465c1f"/>
64+
embedURL="https://stately.ai/registry/editor/embed/1b48bbf1-6f7a-4847-b1e0-47ee5c283371?machineId=68b835cc-49fc-4b9c-972e-a63c01465c1f"
65+
/>
5766

5867
There are several potential events that _can_ happen, but the core states are relatively few to model this behavior. Instead of representing their entire app state in a monolith, the team decided to go with a more modular approach, making use of the [actor model](https://en.wikipedia.org/wiki/Actor_model). This makes maintaining and testing individual components much easier, and it allows for extensibility down the line as project complexity grows.
5968

6069
Handling several logical components does come with some considerations, however. Taylor noted that now that the team had several small components, they needed a way to orchestrate and communicate between them in a cohesive manner. Thankfully, the [XState](https://github.com/statelyai/xstate) framework for composing machines is open source, and the team used it as their base for [`xstate-tree`, an open source framework](https://github.com/koordinates/xstate-tree) for modeling complex UIs as a tree of XState machines. `xstate-tree` couples React views with state machines and composes them as actors in “slots”, allowing them to be exposed to their respective React views. Learn more about all the features `xstate-tree` provides in their [well-documented GitHub repo](https://github.com/koordinates/xstate-tree).
6170

62-
While there are other state management platforms for developers, the team at Koordinates also wanted the ability to co-locate their implementation logic alongside their machines’ definitions, or “blueprints”. This reduces the surface area developers when revisions need to made to their machines. From Taylor:
71+
While there are other state management platforms for developers, the team at Koordinates also wanted the ability to co-locate their implementation logic alongside their machines’ definitions, or “blueprints”. This reduces the surface area developers when revisions need to made to their machines. From Taylor:
6372

6473
> “I love the first class support in XState for side effects. That the side effects can be co-located with my code that triggers it and uses it, instead of having to put them _somewhere else_ like with Redux”
6574
66-
6775
## Handling complex, long-running tasks and edge cases
6876

6977
Being a source control solution for complex datasets, Kart has a naturally complex set of problems to solve as well. Merging, cloning, and loading data all have plenty of considerations, edge cases, and possible failure scenarios, so the team had to take care to address all of them. The ability to map this logic using the Stately Editor proved to be extremely useful.
7078

7179
<EmbedMachine
7280
name="Koordinates List View Machine"
73-
embedURL="https://stately.ai/registry/editor/embed/1b48bbf1-6f7a-4847-b1e0-47ee5c283371?machineId=afa23e5f-11c7-460d-bd98-ff7de694a41d"/>
81+
embedURL="https://stately.ai/registry/editor/embed/1b48bbf1-6f7a-4847-b1e0-47ee5c283371?machineId=afa23e5f-11c7-460d-bd98-ff7de694a41d"
82+
/>
7483

75-
Stately tooling isn’t just for managing UI state. In fact, the logic representing Kart repos is all managed using an XState actor. That actor then watches the filesystem to execute Kart-specific commands and update its own in-memory state.
84+
Stately tooling isn’t just for managing UI state. In fact, the logic representing Kart repos is all managed using an XState actor. That actor then watches the filesystem to execute Kart-specific commands and update its own in-memory state.
7685

7786
Taylor and the team love Stately’s visual editor. Even without domain knowledge of their core product, the logic is still human readable and understandable. Questions like “what happens when a user cancels a clone operation?” and “when is the data model for branches updated?” are easily answered by reading the diagram. Diagramming logic in this way ensured the team was able to build Kart’s functionality in a way that is inherently less prone to bugs and plan for potential errors where possible without wasting time over-engineering for cases that could never occur.
7887

7988
## Moving forward with Stately
8089

81-
By building with Stately’s tooling, the Koordinates team not only simplified their UI and repository state management, but they in turn gave back to the technical community with `xstate-tree`, allowing React developers to better wrangle hosts of machines. Koordinates and Stately are aligned on many core goals: enhancing productivity for their users, strongly committing to open source, and facilitating team collaboration. Naturally, the Stately team was eager for feedback and have committed to the development of features that enhance collaboration without compromise. This includes GitHub synchronization to maintain the repo as the authoritative source and system-wide statechart visualization to facilitate deeper interdisciplinary communication and understanding.
90+
By building with Stately’s tooling, the Koordinates team not only simplified their UI and repository state management, but they in turn gave back to the technical community with `xstate-tree`, allowing React developers to better wrangle hosts of machines. Koordinates and Stately are aligned on many core goals: enhancing productivity for their users, strongly committing to open source, and facilitating team collaboration. Naturally, the Stately team was eager for feedback and have committed to the development of features that enhance collaboration without compromise. This includes GitHub synchronization to maintain the repo as the authoritative source and system-wide statechart visualization to facilitate deeper interdisciplinary communication and understanding.
8291

83-
Koordinates saw a significant leap in efficiency and team collaboration with Stately's tools. [Book a demo with us today](https://calendly.com/d/yc8-3hq-rpc/request-a-demo) to learn how Stately can empower your team to build better software, faster.
92+
Koordinates saw a significant leap in efficiency and team collaboration with Stately's tools. [Book a demo with us today](https://calendly.com/d/yc8-3hq-rpc/request-a-demo) to learn how Stately can empower your team to build better software, faster.

blog/2023-12-01-xstate-v5/index.mdx

+57-40
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,16 @@ const promiseLogic = fromPromise(async ({ input }) => {
7171
```jsx
7272
import { fromTransition } from 'xstate';
7373

74-
const transitionLogic = fromTransition((state, event) => {
75-
switch (event.type) {
76-
// reducer logic; you know the drill
77-
}
78-
}, { count: 0 });
74+
const transitionLogic = fromTransition(
75+
(state, event) => {
76+
switch (
77+
event.type
78+
// reducer logic; you know the drill
79+
) {
80+
}
81+
},
82+
{ count: 0 },
83+
);
7984
```
8085

8186
**Observable actor logic**
@@ -95,11 +100,13 @@ import { fromCallback } from 'xstate';
95100
const callbackLogic = fromCallback(({ sendBack, receive }) => {
96101
const handler = (event) => {
97102
sendBack(event);
98-
}
99-
103+
};
104+
100105
window.addEventListener('message', handler);
101106

102-
return () => { window.removeEventListener('message', handler); }
107+
return () => {
108+
window.removeEventListener('message', handler);
109+
};
103110
});
104111
```
105112

@@ -112,7 +119,7 @@ import { createActor } from 'xstate';
112119

113120
const actor = createActor(someLogic);
114121

115-
actor.subscribe(snapshot => {
122+
actor.subscribe((snapshot) => {
116123
console.log(snapshot);
117124
});
118125

@@ -130,8 +137,8 @@ function withLogging(actorLogic) {
130137
transition: (state, event, actorScope) => {
131138
console.log('State:', state);
132139
return actorLogic.transition(state, event, actorScope);
133-
}
134-
}
140+
},
141+
};
135142
}
136143

137144
const actor = createActor(withLogging(someLogic));
@@ -156,7 +163,7 @@ const actor = createActor(machine, {
156163
// type: '@xstate.snapshot' or
157164
// type: '@xstate.event'
158165
console.log(inspectionEvent);
159-
}
166+
},
160167
});
161168
```
162169

@@ -175,8 +182,8 @@ import { setup, createActor } from 'xstate';
175182

176183
const machine = setup({
177184
actors: {
178-
counter: fromTransition(/* ... */)
179-
}
185+
counter: fromTransition(/* ... */),
186+
},
180187
}).createMachine({
181188
invoke: {
182189
// This will also be persisted!
@@ -293,15 +300,15 @@ const promiseActor = createActor(promiseLogic, {
293300

294301
// From a machine
295302
const machine = setup({
296-
actors: { promiseLogic }
303+
actors: { promiseLogic },
297304
}).createMachine({
298305
invoke: {
299306
src: 'promiseLogic',
300307
input: {
301308
id: 42,
302309
},
303-
}
304-
})
310+
},
311+
});
305312
```
306313

307314
Actors can also have [output](/docs/output), which represents their “done data” when they have reached their final state. It’s not just state machines that can have output; promise logic naturally resolves with output, and it may be possible to specify output for other actor logic types in the future.
@@ -385,20 +392,30 @@ const machine = setup({
385392
}).createMachine({
386393
initial: 'green',
387394
states: {
388-
green: {/* ... */},
389-
yellow: {/* ... */},
395+
green: {
396+
/* ... */
397+
},
398+
yellow: {
399+
/* ... */
400+
},
390401
red: {
391402
initial: 'walk',
392403
states: {
393-
walk: {/* ... */},
394-
run: {/* ... */},
395-
stop: {/* ... */}
396-
}
397-
}
398-
}
404+
walk: {
405+
/* ... */
406+
},
407+
run: {
408+
/* ... */
409+
},
410+
stop: {
411+
/* ... */
412+
},
413+
},
414+
},
415+
},
399416
});
400417

401-
const actor = createActor(machine)
418+
const actor = createActor(machine);
402419
actor.start();
403420

404421
// Strongly-typed state values!
@@ -423,24 +440,24 @@ const machine = setup({
423440
actions: {
424441
greet: (_, params: { name: string }) => {
425442
console.log(`Hello, ${params.name}!`);
426-
}
443+
},
427444
},
428445
guards: {
429446
isGreaterThan: (_, params: { value: number; min: number }) => {
430447
return params.value > params.min;
431-
}
432-
}
448+
},
449+
},
433450
}).createMachine({
434451
context: ({ input }) => ({
435452
user: input.user,
436-
count: 0
453+
count: 0,
437454
}),
438455
entry: {
439456
type: 'greet',
440457
// highlight-start
441458
params: ({ context }) => ({
442-
name: context.user.name
443-
})
459+
name: context.user.name,
460+
}),
444461
// highlight-end
445462
},
446463
on: {
@@ -450,12 +467,12 @@ const machine = setup({
450467
// highlight-start
451468
params: ({ context, event }) => ({
452469
value: context.count,
453-
min: 0
454-
})
470+
min: 0,
471+
}),
455472
// highlight-end
456-
}
457-
}
458-
}
473+
},
474+
},
475+
},
459476
});
460477
```
461478

@@ -471,7 +488,7 @@ const machine = createMachine({
471488
entry: enqueueActions(({ context, event, enqueue, check }) => {
472489
// assign action
473490
enqueue.assign({
474-
count: context.count + 1
491+
count: context.count + 1,
475492
});
476493

477494
// Conditional actions (replaces choose(...))
@@ -495,7 +512,7 @@ const machine = createMachine({
495512
}
496513

497514
// no return
498-
})
515+
}),
499516
});
500517
```
501518

@@ -543,7 +560,7 @@ const userMachine = setup({
543560
isAuthenticated: ({ context }) => context.user !== undefined,
544561
isAdmin: ({ context }) => context.user.role === 'admin',
545562
isBanned: ({ context }) => context.user.status === 'banned',
546-
}
563+
},
547564
}).createMachine({
548565
// ...
549566
on: {

blog/2023-12-07-tidefi-and-stately-case-study/index.mdx

+10-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ I was able to showcase the machine visualizer to the rest of the company, which
5959

6060
Several months down the road, our team was running into some challenges of transmitting data between pages. Most pages had a machine that controlled the flow, and then there were other machines meant for data subscriptions, connection handling, etc. I decided to model a traditional hub-and-spoke actor system by:
6161

62-
<ol style={{'list-style-type': 'lower-alpha'}}>
63-
<li>nesting actors underneath a root actor</li>
64-
<li>broadcasting an INIT event to register actors and facilitate storing references</li>
65-
<li>handle some communication via broadcasts, and others as direct events or data queries</li>
62+
<ol style={{ 'list-style-type': 'lower-alpha' }}>
63+
<li>nesting actors underneath a root actor</li>
64+
<li>
65+
broadcasting an INIT event to register actors and facilitate storing
66+
references
67+
</li>
68+
<li>
69+
handle some communication via broadcasts, and others as direct events or
70+
data queries
71+
</li>
6672
</ol>
6773

6874
In the [XState Discord](https://discord.stately.ai), this concept came up several times, and my implementation was tweaked until it was fairly easy to reason with, and performant. To my delight, the XState team created an RFC to introduce actor systems and the “receptionist” pattern! It was a joy to have real-world experience to contribute to the discussion and prove or challenge parts of the API. Now it is a built-in part of XState v5! I can remove dozens of lines of code and instead utilize my root actor as a system with individually named actors in a tree underneath.

blog/2023-12-29-end-of-year-changelog/index.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Your machine’s context is now displayed on the canvas. You can add your contex
2222

2323
## Add transition
2424

25-
When a transition selected, you can now use the arrow icon button to add another transition for quick conditional logic. Using the button will add a transition from the same source state, making the original transition into an *if* transition and the new transition into an *else* transition, where you can then add your [guard logic](/docs/guards).
25+
When a transition selected, you can now use the arrow icon button to add another transition for quick conditional logic. Using the button will add a transition from the same source state, making the original transition into an _if_ transition and the new transition into an _else_ transition, where you can then add your [guard logic](/docs/guards).
2626

2727
![A selected transition with the next label. Using the arrow icon button adds a new transition from the same source state. The first transition is then labeled 1 next IF new guard. The second transition is labeled 2 next ELSE.](add-transition.gif)
2828

@@ -45,4 +45,4 @@ You can now use the **Show/hide effects on canvas** option in the editor menu vi
4545
- We fixed a bug where you could sometimes be redirected to the Project settings page when creating a new machine.
4646
- You can now remove [state and event descriptions](/docs/descriptions) without any issues. To delete a description, remove its text. To remove the description area from a state or event, delete its text from the details panel.
4747
- We fixed a bug with the CodeSandbox and StackBlitz exports when using XState V5.
48-
- You can now undo when you use the **Clear** button on a machine at [state.new](https://state.new).
48+
- You can now undo when you use the **Clear** button on a machine at [state.new](https://state.new).

blog/2024-01-02-office-hours/index.mdx

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tags:
1111
stately inspect,
1212
github sync,
1313
sources,
14-
roadmap
14+
roadmap,
1515
]
1616
authors: [laura]
1717
date: 2024-01-02
@@ -43,5 +43,4 @@ Watch the video to find out about our new features and plans for 2024. Use the l
4343
- [47:04 Can guards assign new data to the machine state?](https://youtube.com/watch?v=x-F1TPjz_lI&t=2824s)
4444
- [50:52 How to stay updated with the Stately team](https://youtube.com/watch?v=x-F1TPjz_lI&t=3052s)
4545

46-
47-
Be the first to find out about our next office hours by subscribing to [our YouTube channel](https://www.youtube.com/@Statelyai), [Twitch channel](https://www.twitch.tv/statelyai), or [following us on LinkedIn](https://www.linkedin.com/company/statelyai/).
46+
Be the first to find out about our next office hours by subscribing to [our YouTube channel](https://www.youtube.com/@Statelyai), [Twitch channel](https://www.twitch.tv/statelyai), or [following us on LinkedIn](https://www.linkedin.com/company/statelyai/).

0 commit comments

Comments
 (0)