Skip to content
Isaac Pak edited this page Dec 2, 2017 · 3 revisions

Instantiate the client and pass it on to the middleware

Wherever you create your store include the client. This is where we will instantiate the client and pass it in the middleware.

// app root
// services
   // socketio
      // index.js
// store.js
// store.js
import Socket from './services/socketio/index.js'
import {createStore, applyMiddleware} from 'redux'
import ioMiddleware from 'redux-socketio'
const SocketClient = new Socket()

const store = createStore(
    ... 
    applyMiddleware(ioMiddleware(SocketClient))
    ... 
)

...
export default store
Clone this wiki locally