UNPKG

650 BJavaScriptView Raw
1import io from 'socket.io-client'
2import { createStore, applyMiddleware, compose } from 'redux'
3import { clientMiddleware, reducerEnhancer, serverAction } from '../src'
4
5const socket = io("http://localhost:2001")
6
7const reducer = reducerEnhancer()
8
9const store = createStore(
10 reducer,
11 compose(
12 applyMiddleware(
13 clientMiddleware(socket)
14 )
15 )
16)
17
18store.subscribe(() => {
19 console.log("\nNEXT_STATE\n")
20
21 console.log(store.getState())
22})
23
24store.dispatch(
25 serverAction({
26 type: "resolve",
27 meta: {
28 requestName: "action.resolve"
29 }
30 })
31)
32
33store.dispatch(
34 serverAction({
35 type: "reject",
36 meta: {
37 requestName: "action.reject"
38 }
39 })
40)
\No newline at end of file