Nexus Flux socket.io Adapter
Nexus Flux
Abstract Nexus Flux Diagram
+-> Action.dispatch ---+--> Client.Events ---+--> Action.onDispatch -+
| Fire & forget Stream Callback |
Component logic Adapter Adapter Global logic
| Callback Stream Fire & forget |
+-- Store.onUpdate <--+--- Server.Events <--+------ Store.update ---+
This package implements the socket.io adapter for Nexus Flux to implement Flux over the Wire.
Over the wire Nexus Flux Diagram using Websockets (with socket.io fallback)
in the browser socket.io frames in the server
Component #A1 <---+
|
Component #A2 <---+-- SocketIOAdapter -+
| Client A |
Component #A3 <---+ |
+-> Global logic
Component #B1 <---+ |
| |
Component #B2 <---+-- SocketIOAdapter -+
| Client B
Component #B3 <---+
Usage
Share global server-side app state across all connected clients.
// Client side: runs in the browser or in a node process;const client = );
// Server side: runs in a node process, which may or may not be the same process;const server = 8080;
Client usage example (in a React view)
{ thislifespan = ; return todoList: thispropsfluxvalue ; } { thispropsflux ; thisremoveItem = thispropsfluxdispatch; } { thislifespan; } { return thisstatetodoList ? todoList : null; }
Server usage example
const todoList = server;const removeItem = server; todoList; removeItem;
Installation
This package is written in ES6/7. You will need babel
to run it.