Skip to content

Instantly share code, notes, and snippets.

View adamschachne's full-sized avatar

Adam Schachne adamschachne

View GitHub Profile
@adamschachne
adamschachne / socketMiddleware.js
Created August 18, 2018 23:01
Redux WebSocket middleware
import { Socket } from './Socket';
export const createSocketMiddleware = (host, port) => store => {
const socket = new Socket(host, port);
socket.onopen = () => {
store.dispatch({ type: "SOCKET_OPEN" });
}
socket.onclose = () => {