What is the best practive to use Valtio with streaming and suspense #708
Unanswered
ivan-angjelkoski
asked this question in
Q&A
Replies: 1 comment
-
Valtio isn't really specifically designed for streaming, but you should be able to do something like this. const messagesProxy = proxy({ messages: Promise.resolve([]) });
const addMessage = (newMessage) => {
messagesProxy.messages = messagesProxy.messages.then((prev) => [...prev, newMessage])
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
lets say i have a
messagesProxy
proxy const, that looks like this:{messages: []}
.how can i first fetch the current messages, and then stream new messages to it, using suspense.. what is the best practice?
Beta Was this translation helpful? Give feedback.
All reactions