Connecting to Redux
Get a general overview of how to communicate via WebSockets.
The general Redux architecture is all about sending well-defined messages to the store. This same scheme can work perfectly for server communication over WebSockets. We can send the same structure of a plain object with the type
property to the server, and receive a similarly structured response:
> TO-SERVER: { type: 'GET_USER', id: 100 }
< FROM-SERVER: { type: 'USER_INFO', data: { ... }}
A more robust example might be a chat server, where we can dispatch to the store a message similar to { id: 'XXX', type: 'ADD_MESSAGE', msg: 'Hello' }
.
Get hands-on with 1200+ tech skills courses.