Describe the bug
I'm not sure if this is a bug or if my understanding of createOptimistic/action is flawed but sometimes I have a hard time understanding how these work together. If it's not a bug then I find it fairly unintuitive.
I created a stackblitz example here. In it there are 2 versions of a todo example with a simulated backend. The first one uses createOptimisticStore as the way to store the todos, the second one just uses createStore instead.
In the optimistic example a lot of it works the way I would expect. You can add or remove todos and the updates show up straight away. In the store example there is a pause while it waits for the backend work to complete.
However, in the store example it behaves in an optimistic way for updating todos. Marking a todo as done or updating it's name shows up straight away, it doesn't wait. I don't really understand what I'm doing differently between adding/removing vs updating.
The second thing that I find more confusing is that in the optimistic example, clicking the save button on a todo after editing it causes it to wait, setIsEditing(false) doesn't resolve until the transition is finished. While in the store example this doesn't happen. Which seems reversed to me, why is the optimistic version waiting? Also, the isEditing is just an ordinary signal, why is its behaviour tied to whether I use a store or an optimistic store?
Your Example Website or App
https://stackblitz.com/edit/vitejs-vite-faxvqtln?file=src%2FTodo.tsx
Steps to Reproduce the Bug or Issue
- Go to https://stackblitz.com/edit/vitejs-vite-faxvqtln
- Add a todo
- Edit the todo's name
- Save the todo.
There is a wait time before isEditing() returns false again
- Click on "Store" at the top
- Add a todo
- Edit the todo's name
- Click save
There is no wait time for isEditing() to return false again
Expected behavior
.
Screenshots or Videos
No response
Platform
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
Additional context
No response
Describe the bug
I'm not sure if this is a bug or if my understanding of
createOptimistic/actionis flawed but sometimes I have a hard time understanding how these work together. If it's not a bug then I find it fairly unintuitive.I created a stackblitz example here. In it there are 2 versions of a todo example with a simulated backend. The first one uses
createOptimisticStoreas the way to store the todos, the second one just usescreateStoreinstead.In the optimistic example a lot of it works the way I would expect. You can add or remove todos and the updates show up straight away. In the store example there is a pause while it waits for the backend work to complete.
However, in the store example it behaves in an optimistic way for updating todos. Marking a todo as done or updating it's name shows up straight away, it doesn't wait. I don't really understand what I'm doing differently between adding/removing vs updating.
The second thing that I find more confusing is that in the optimistic example, clicking the save button on a todo after editing it causes it to wait,
setIsEditing(false)doesn't resolve until the transition is finished. While in the store example this doesn't happen. Which seems reversed to me, why is the optimistic version waiting? Also, theisEditingis just an ordinary signal, why is its behaviour tied to whether I use a store or an optimistic store?Your Example Website or App
https://stackblitz.com/edit/vitejs-vite-faxvqtln?file=src%2FTodo.tsx
Steps to Reproduce the Bug or Issue
There is a wait time before
isEditing()returns false againThere is no wait time for
isEditing()to return false againExpected behavior
.
Screenshots or Videos
No response
Platform
Additional context
No response