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