Skip to content

An experimental client-server message-driven structure using redux and websockets.

License

Notifications You must be signed in to change notification settings

manufont/redux-full-socket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redux-full-socket

An experimental client-server message-driven structure using redux and websockets.

The purpose of this project is to extends redux life cycle outside the client with websockets, by providing an API to its dispached actions.

Redux is used on both client and server in order to reuse client reducer. It has several benefits:

  • CRUD tasks only needs to be implemented once
  • The backend behaviour is entirely predictable: most server verifications may be avoided, resulting in an instant feedback for the client
  • Actions can be broadcasted to every client that shares the same channel (e.g mobile & destop), which lets you maintain a synced state accross devices

The server-side store can include additionnal reducers for server-specific data (e.g. statistics).

The library consists of a server and 2 redux store enhancers: one for the client, one for the server.

demos

Counter

Arena

Snake

Piano

actions API

By default, an action will be sent and dispatched to the server asynchronously, while dispatching it to the client store (short cycle). That way, the data is updated in real-time and the state is saved server-side.

You can control how an action travels through the cycle by extending it with these properties :

Name Type Default Description
sync bool false If true, the action will be sent and dispatched synchronously to the server before being dispatched to the client (long cycle)
hide bool false If true, the action will not be sent at all to the server. This may be useful for non-critical events
broadcast bool false If true, the action will be dispatched to every client that shares the same credentials (short cycle for sender, long cycle for receivers)

Alt text

progress

The project is at its very beginning.

For now, the server-side persistence is achieved by using redux-persist with a custom async storage using node_redis. In the long term, data will be persisted using an event-sourcing pattern.

The server-side state architecture needs to be improved.

Also, the project could benefit from socket.io Room & Namespace features.

installation

Clone the repo, then launch the server

npm run server

Start another terminal and launch the client app

npm start

It'll open the demo app in browser, which is a counter with (ultra basic) user management.

documentation

No documentation yet. Check out the methods exported by /src/lib and redux-full-socket-server, and see how they're called in server/ and src/demos/.

About

An experimental client-server message-driven structure using redux and websockets.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published