Repository navigation
Replies: 2 comments 1 reply
|
@prc5, hi, what do you think about it? By the way, it would be cool to connect it with the REST initial state as well, if the idea works out. |
1 reply
|
The more I think about it, the more I realize there are quite a few architectural details to consider, especially how state accumulation would interact with existing delivery strategies, multiple subscribers, and the listener lifecycle. The public API could be pretty simple, but getting the internals right seems much trickier. I'll consider different variants of how it could be implemented. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi!
I'd like to hear your thoughts on a possible approach to handling stateful WebSocket subscriptions in HyperFetch.
Some WebSocket APIs send an initial snapshot followed by incremental updates (upsert, delete, etc.). Currently, handling this requires maintaining accumulated state separately, for example using React state or Zustand.
I was wondering whether it would make sense to support optional state accumulation directly within listeners.
Here are two possible API approaches:
Option 1: Add
stateto existing listenersOption 2: Introduce
createStatefulListenerIn both cases, the idea would be to accumulate state as events arrive, share it across subscribers, and expose the current snapshot through
getState().These are just rough ideas, not a concrete feature proposal. I'd be interested to hear whether you see value in something like this, and which approach (if any) would fit HyperFetch's architecture better.
Thanks!
All reactions