/** @module setting/state */ /** * state.js * * Collection of everything which has to do with state changes. **/ /** actionTypes define what actions are handeled by the reducer. */ export const actions = { changePaginationPage: page => { return { type: 'TABLE_CHANGE_PAGINATION_PAGE', page } }, changePaginationItems: items => { return { type: 'TABLE_CHANGE_PAGINATION_ITEMS', items } } } console.log('State actions', actions) /** state definition */ export const state = { filters: {}, sorting: {}, pagination: { activePage: 0, items: 50 } } console.log('State state', state) /** reducer is called by the redux dispatcher and handles all component actions */ export function reducer (state = [], action) { let pagination switch (action.type) { case 'TABLE_CHANGE_PAGINATION_PAGE': pagination = { ...state.pagination } pagination.activePage = action.page return { ...state, pagination } case 'TABLE_CHANGE_PAGINATION_ITEMS': pagination = { ...state.pagination } pagination.items = action.items return { ...state, pagination } default: return state } } /** sagas are asynchronous workers (JS generators) to handle the state. */ export function * saga () {}