Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Implement the WebSocket logic using middleware #715

Closed
programarivm opened this issue Feb 7, 2024 · 1 comment · Fixed by #716 or #718
Closed

Implement the WebSocket logic using middleware #715

programarivm opened this issue Feb 7, 2024 · 1 comment · Fixed by #716 or #718
Labels
enhancement New feature or request

Comments

@programarivm
Copy link
Member

programarivm commented Feb 7, 2024

This WebSocket logic needs to be implemented using middleware for better scalability with server-side rendered frameworks like Next.js.

See:

Keep it up,

@programarivm
Copy link
Member Author

programarivm commented Feb 9, 2024

It seems as if the use of store.getState() is absolutely fine in the RTK app for implementing the WebSocket logic in three static JS classes. However, if planning to make this compatible for an RTK + Next.js integration, it looks like the WebSocket logic needs to be implemented as middleware. There are generally a lot of alternatives that don't involve importing the store directly. The less the store is treated as a singleton, the easier the code becomes to test because the same logic can be called with any store instance rather than the single one exported from store.js.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
1 participant