Skip to content

Docs(faq): Where should persistent connections live? #2944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/faq/CodeStructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [What should my file structure look like? How should I group my action creators and reducers in my project? Where should my selectors go?](#structure-file-structure)
- [How should I split my logic between reducers and action creators? Where should my “business logic” go?](#structure-business-logic)
- [Why should I use action creators?](#structure-action-creators)

- [Where should websockets and other persistent connections live?](#structure-persistent-connections)

## Code Structure

Expand Down Expand Up @@ -102,3 +102,12 @@ Action creators are a more powerful abstraction. Creating an action often involv
**Discussions**

- [Reddit: Redbox - Redux action creation made simple](https://www.reddit.com/r/reactjs/comments/54k8js/redbox_redux_action_creation_made_simple/d8493z1/?context=4)


<a id="structure-persistent-connections"></a>
### Where should websockets and other persistent connections live?

It is highly recommended to put any kind of persistent connection into middleware. Which should intercept needed actions and also handle any complex logic or [side effects](/faq/actions#actions-side-effects) it may produce. It is also possible to put persistent connections into the store state, but you should be aware that it may cause some [issues](/faq/organizing-state#organizing-state-non-serializable).

**Libraries**
- [Middleware: Socket and Adapters](https://github.com/markerikson/redux-ecosystem-links/blob/master/middleware-sockets-adapters.md)