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