useXxxApi: use PollingReducer as a configuration provider provide pushAPIs, which update respective state with: pushing status push result PollingReducer: rename to configurationReducer move polling indication to it's respective state XxxState.polling = 'true/false' Reviewed-on: http://192.168.8.55:3000/HQLAx/CordaCheckers/pulls/34
24 lines
473 B
JavaScript
24 lines
473 B
JavaScript
import { useReducer } from 'react';
|
|
import { nextState } from '../util/StateHelper';
|
|
|
|
const initialState = {
|
|
table: null,
|
|
|
|
// Network
|
|
isPollingTable: false
|
|
};
|
|
|
|
function reducer(state, action) {
|
|
switch (action.type) {
|
|
|
|
case 'next':
|
|
return nextState(state, action);
|
|
|
|
default:
|
|
throw Error('LeaderboardReducer: unknown action.type', action.type);
|
|
}
|
|
}
|
|
|
|
export default function useLeaderboardReducer() {
|
|
return useReducer(reducer, initialState);
|
|
} |