It's limited. The UI is basically just a loop that does the stuff, and I'm not going to get into how fine-grained rendering is amazing here. But generally speaking, if I go in here and add some code and go, like, hey, you know, it does the thing, right? If we can check these boxes, we can remove it. This is pretty standard application, and it basically, as you expect, you just, like, do some mutations on the store. You add a to-do, filter the to-do, find it, and mark it as completed. This is fairly straightforward.
But now, what if we want to make it async? Now, if I had more time, I'd actually do this live code, but since I don't, I am going to just jump ahead and show the tools we did today with a working demo. So we do a couple things. We now, I've created a server, and the server is just kind of faked. It's just an array in another file with some delays in it. But generally, I've exposed them through this DB thing. So basically, now what we do is we get our data from the server, we go db.get to-dos in our create async. And then we derive our store from this data.
I did one other little thing, which I called this an optimistic store, because I want optimistic updates. If I didn't do this, we wouldn't have the optimistic updates. But I was able to take the exact same code we wrote previously, like the set to-dos, the filter, and keep that in our example. And then just wrap that code in a transition. We support async functions as well, but you have to do this funny thing where you call start transition today, because we don't have async context, if you've ever seen any of the React demos recently. So I'm just going to use the generator form. We're kind of playing with APIs still.
Comments