David K. 🎹's Avatar

David K. 🎹

@davidkpiano.bsky.social

State machine. Building stately.ai

8,672 Followers  |  116 Following  |  31 Posts  |  Joined: 23.04.2023  |  1.9229

Latest posts by davidkpiano.bsky.social on Bluesky

Preview
Build the Future of AI-Native UX in 4 Hours | Web Dev Challenge Season 2 How will websites evolve if it's all powered by AI?

the latest Web Dev Challenge is available to everyone!

@algolia.bsky.social asked 3 teams of devs to imagine what the UX of an AI-native web app might look like. featuring @davidkpiano.bsky.social, @shaw.city, Nadirah, @aguywhocodes.com, Syscily, and Camille, with @chuckm.bsky.social

15.07.2025 19:12 β€” πŸ‘ 13    πŸ” 7    πŸ’¬ 0    πŸ“Œ 2
Preview
Build the Future of AI-Native UX in 4 Hours | Web Dev Challenge Season 2 How will websites evolve if it's all powered by AI?

new Web Dev Challege is up early for supporters!

watch Syscily, Camille, Nadirah, @aguywhocodes.com, @shaw.city, and @davidkpiano.bsky.social as they imagine what UX might look like in an AI-native app, sponsored by @algolia.bsky.social with @chuckm.bsky.social as our advisor

codetv.link/wdc/s2e6

14.07.2025 03:53 β€” πŸ‘ 12    πŸ” 3    πŸ’¬ 1    πŸ“Œ 1
Stephen and David of the Keyframers working at desks in CodeTV Studio

Stephen and David of the Keyframers working at desks in CodeTV Studio

helping the Keyframers reunion happen over here @davidkpiano.bsky.social @shaw.city

18.06.2025 21:05 β€” πŸ‘ 29    πŸ” 3    πŸ’¬ 4    πŸ“Œ 1

Great to hear! Open to any suggestions or ideas

07.06.2025 23:51 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

Yes it does! Since stores are atoms, you can combine/derive state from stores and other atoms.

In the future, atoms can be used inside store context reactively.

13.05.2025 15:19 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

Yes, like Zustand and Jotai combined, but framework agnostic

13.05.2025 14:54 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
// Regular atoms
const countAtom = createAtom(1);
countAtom.get(); // 1
const flavorAtom = createAtom('chocolate');

// Derived atom that combines both
const donutMessageAtom = createAtom(() => {
  const count = countAtom.get();
  const flavor = flavorAtom.get();
  return `${count} ${flavor} donut${count === 1 ? '' : 's'}`;
});

console.log(donutMessageAtom.get()); // "1 chocolate donut"

countAtom.set(3);
console.log(donutMessageAtom.get()); // "3 chocolate donuts"

flavorAtom.set('strawberry');
console.log(donutMessageAtom.get()); // "3 strawberry donuts"

// Regular atoms const countAtom = createAtom(1); countAtom.get(); // 1 const flavorAtom = createAtom('chocolate'); // Derived atom that combines both const donutMessageAtom = createAtom(() => { const count = countAtom.get(); const flavor = flavorAtom.get(); return `${count} ${flavor} donut${count === 1 ? '' : 's'}`; }); console.log(donutMessageAtom.get()); // "1 chocolate donut" countAtom.set(3); console.log(donutMessageAtom.get()); // "3 chocolate donuts" flavorAtom.set('strawberry'); console.log(donutMessageAtom.get()); // "3 strawberry donuts"

import { createAsyncAtom } from '@xstate/store';

const donutOrderAtom = createAsyncAtom(async () => {
  const order = { flavor: 'glazed', quantity: 12 };
  const data = await submitDonutOrder(order);
  return data;
});

donutOrderAtom.subscribe((state) => {
  if (state.status === 'pending') {
    console.log('🧾 Placing your order...');
  } else if (state.status === 'done') {
    console.log('🍩', state.data);
  } else if (state.status === 'error') {
    console.log('😒 Order failed:', state.error);
  }
});

import { createAsyncAtom } from '@xstate/store'; const donutOrderAtom = createAsyncAtom(async () => { const order = { flavor: 'glazed', quantity: 12 }; const data = await submitDonutOrder(order); return data; }); donutOrderAtom.subscribe((state) => { if (state.status === 'pending') { console.log('🧾 Placing your order...'); } else if (state.status === 'done') { console.log('🍩', state.data); } else if (state.status === 'error') { console.log('😒 Order failed:', state.error); } });

βš›οΈ XState Store now has atoms, and they're *really* simple.

β†’ atom.get()
β†’ atom.set(…)
β†’ Derived atoms (reactive)
β†’ Async atoms
β†’ Stores are atoms too!

npm i @xstate/store

stately.ai/docs/xstate-...

13.05.2025 14:38 β€” πŸ‘ 33    πŸ” 7    πŸ’¬ 1    πŸ“Œ 0
@xstate/store | Stately Version 3.x (Version 2.x docs)

Yes, there's a guide here:

stately.ai/docs/xstate-...

May even make a codemod πŸ€”

10.03.2025 14:17 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

XState Store!

05.03.2025 22:32 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

I like state machines. I still struggle a bit to get my mind bent into state machine shape, but I’m always so happy with the quality of what I build when I do

07.01.2025 23:48 β€” πŸ‘ 79    πŸ” 2    πŸ’¬ 5    πŸ“Œ 0

Fixing that soon!

13.01.2025 16:27 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

That's it, I'm switching to xstate store

26.12.2024 22:06 β€” πŸ‘ 65    πŸ” 3    πŸ’¬ 6    πŸ“Œ 1

How would you simplify XState?

Planning for the next major version, and would love to hear your thoughts and ideas ✍️

18.12.2024 17:32 β€” πŸ‘ 18    πŸ” 1    πŸ’¬ 7    πŸ“Œ 0

Would love to hear your ideas!

12.12.2024 23:54 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
The Angular+ Show logo. S8E811. β€œState Machines and XState in Angular with David Khourshid. Hosts  Q, Lara Newsom, Jan-Niklas Vortmann, Chau Tran and Brian Love."  Photos of the hosts. Photo of David .

The Angular+ Show logo. S8E811. β€œState Machines and XState in Angular with David Khourshid. Hosts Q, Lara Newsom, Jan-Niklas Vortmann, Chau Tran and Brian Love." Photos of the hosts. Photo of David .

Join us on today's episode as we interview David Khourshid @davidkpiano.bsky.social. We will learn about state machines and how XState plays nice with #Angular right out of the box! #ngconf
🍎https://apple.co/4ipNHcP
🟒 spoti.fi/3VxlGGq

09.12.2024 23:31 β€” πŸ‘ 8    πŸ” 3    πŸ’¬ 0    πŸ“Œ 0

I now *really* enjoy reading articles that are so obviously human-written, mistakes and all

07.12.2024 22:43 β€” πŸ‘ 149    πŸ” 2    πŸ’¬ 6    πŸ“Œ 1

I'd love to! Next year.

06.12.2024 19:49 β€” πŸ‘ 7    πŸ” 0    πŸ’¬ 2    πŸ“Œ 0

I don't like default exports.

They exist in JS because they're "simpler", even though they're more verbose:

export default Thing
import Thing from './thing'

vs.

export { Thing }
import { Thing } from './thing'

Just use consistent naming & don't be afraid of typing curly braces.

05.12.2024 18:50 β€” πŸ‘ 81    πŸ” 8    πŸ’¬ 12    πŸ“Œ 0
Video thumbnail

Updated demo of Decode generating state-machines from diagrams, this time with streaming generation support

Then I do the reverse, generating a diagram from an implementation.

The diagram auto-layout is still rough. I'll work work on more robust auto-layout soon.

01.12.2024 21:25 β€” πŸ‘ 32    πŸ” 6    πŸ’¬ 3    πŸ“Œ 0

This is incredible

02.12.2024 05:51 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

πŸ”² Merge Conflict: Accept All Current
πŸ”² Merge Conflict: Accept All Incoming
β˜‘οΈ Merge Conflict: Accept the things I cannot change, the courage to change the things I can, and the wisdom to know the difference

02.12.2024 04:16 β€” πŸ‘ 164    πŸ” 19    πŸ’¬ 4    πŸ“Œ 1
Preview
How to Grow Professional Relationships A practical, science-backed model for growing quality professional relationships.

I wrote an essay about relationships that may be helpful for personal career development (and maybe devrel).

Mentioned in the post (by name): @davidkpiano.bsky.social, @kentcdodds.com, @joshuakgoldberg.com, @jennytru.bsky.social, @acemarke.dev, and others

tej.as/blog/how-to-...

28.11.2024 16:05 β€” πŸ‘ 41    πŸ” 8    πŸ’¬ 0    πŸ“Œ 0

I love it

25.11.2024 21:42 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

2025?

23.11.2024 04:40 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

Component State Management in React:
- useState
- useMachine

That's it. That's all I use anymore.

21.11.2024 16:08 β€” πŸ‘ 53    πŸ” 4    πŸ’¬ 9    πŸ“Œ 2

AI is trained on all code, not good code

18.11.2024 22:55 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

Oh my God

15.11.2024 03:35 β€” πŸ‘ 7    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

FSMs are the best way to model UI state. What can we do to indoctrinate people to this fact?

09.11.2024 00:51 β€” πŸ‘ 32    πŸ” 2    πŸ’¬ 18    πŸ“Œ 1

🀝

04.11.2024 22:20 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

Sorry, got stuck in traffic

30.10.2024 16:37 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

@davidkpiano is following 20 prominent accounts