Streamlining multiple streaming update endpoints via WebSocket #4120
Unanswered
simonvizzini
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've implemented streaming updates in our application via the
onCacheEntryAdded
callback as described in the documentation.This requires quite a bit of boilerplate code, especially if you have multiple topics you want to subscribe to via WebSockets this results in a lot of code duplication.
I studied the documentation and code to see how this could be more streamlined. So far the only option I have found is to create a factory function for
onCacheEntryAdded
. What I don't like about this solution is the difficulty of typing this factory function properly. I had to import a few types from RTKs/dist
folder, which means they are not part of the publicly exported API of the module and may change anytime in the future without notice.Here is the implementation I came up with so far:
Which can then be used as follows:
This works but providing a custom
updateCacheData
function is a bit awkward, as you need two arguments: thedata
from the event as well as thedraft
, and the types might not be the same.How does everyone else solve multiple streaming update endpoints, without having to repeat too much boilerplate code?
Beta Was this translation helpful? Give feedback.
All reactions