I want to create a reusable reduct table module that will store and update the page number, displayed pages, etc., which I can share between all my pages.
However, I need refresh actions to trigger the refreshdata action, which will depend on a different endpoint depending on the page.
So maybe something similar to a specific page listens for the RefreshData action, and then starts another action. What would be the best way to achieve this? I am currently using recycling for my middleware, but am looking at sound reductions.
What is the best way to achieve this?
** To clarify **
I have tables on multiple pages / projects and I want to minimize code duplication. I thought I could make a droppable redux module (action + reducer) and then just specify a handler for the REFRESH_DATA action separately, so I would not need to set the keys in this file. I think with redux-saga I could listen to the REFRESH_DATA action and have a switch depending on the current page? Or any of the best deals.
export const ITEMS_PER_PAGE_UPDATED = 'ITEMS_PER_PAGE_UPDATED' export const CURRENT_PAGE_UPDATED = 'CURRENT_PAGE_UPDATED' export const REFRESH_DATA = 'REFRESHDATA' export const DATA_REFRESHED = 'REFRESHDATA' export function currentPageUpdated(value) { return function (dispatch) { dispatch({ type: CURRENT_PAGE_UPDATED, value }) dispatch({type:REFRESH_DATA}) } } export function itemsPerPageUpdated(value) { return function (dispatch) { dispatch({ type: ITEMS_PER_PAGE_UPDATED, value }) dispatch({type:REFRESH_DATA}) } } function reducer(state={ pageNumber:1, pageSize:10, totalItems:0, totalPages:1, sortColumn:null, sortAscending:true }, action) { switch(action.type) { case ITEMS_PER_PAGE_UPDATED: return Object.assign({}, state, {pageSize: action.value, pageNumber:1}) case CURRENT_PAGE_UPDATED: return Object.assign({}, state, {pageNumber: action.value}) case DATA_REFRESHED: return Object.assign({}, state, {totalPages: action.values.totalPages, totalItems:action.values.totalItems}) default: return state } } export default reducer