github.com/stampzilla/stampzilla-go@v2.0.0-rc9+incompatible/nodes/stampzilla-server/web/src/ducks/devices.js (about) 1 import { Map, fromJS } from 'immutable'; 2 import { defineAction } from 'redux-define'; 3 4 const c = defineAction( 5 'devices', 6 ['UPDATE'], 7 ); 8 9 const defaultState = Map({ 10 list: Map(), 11 }); 12 13 // Actions 14 export function update(connections) { 15 return { type: c.UPDATE, connections }; 16 } 17 18 // Subscribe to channels and register the action for the packages 19 export function subscribe(dispatch) { 20 return { 21 devices: devices => dispatch(update(devices)), 22 }; 23 } 24 25 // Reducer 26 export default function reducer(state = defaultState, action) { 27 switch (action.type) { 28 case c.UPDATE: { 29 return state 30 .set('list', fromJS(action.connections)); 31 } 32 default: return state; 33 } 34 }