Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 30x 30x 30x 3x 3x 3x 5x 5x 18x 18x 1x 1x 5x 3x 1x 3x 1x | import { AppState, IndexedAction } from "./types"; import { errors, getIndexedAction, loading, meta, progress } from "./utils"; export function loadingSelector(...actions: (IndexedAction | string)[]) { const indexedActions: IndexedAction[] = actions.map(action => getIndexedAction(action) ); return (state: AppState): boolean => indexedActions.reduce( ( previousValue: boolean, { actionType, actionIndex }: IndexedAction ): boolean => { const loadingList = loadingListSelector(actionType)(state); return ( previousValue || Boolean(loadingList ? loadingList[actionIndex] : false) ); }, false ); } export function progressSelector(actionOrActionType: IndexedAction | string) { const { actionType, actionIndex } = getIndexedAction(actionOrActionType); return (state: AppState): any => { const progressList = progressListSelector(actionType)(state); return progressList ? progressList[actionIndex] : undefined; }; } export function errorSelector(actionOrActionType: IndexedAction | string) { const { actionType, actionIndex } = getIndexedAction(actionOrActionType); return (state: AppState): any => { const errorList = errorListSelector(actionType)(state); return errorList ? errorList[actionIndex] : undefined; }; } export function metaSelector(actionOrActionType: IndexedAction | string) { const { actionType, actionIndex } = getIndexedAction(actionOrActionType); return (state: AppState): any => state.status[meta(actionType)] ? state.status[meta(actionType)][actionIndex] : undefined; } export const loadingListSelector = (actionType: string) => ( state: AppState ): any | undefined => state.status[loading(actionType)] ? state.status[loading(actionType)] : undefined; export const progressListSelector = (actionType: string) => ( state: AppState ): any | undefined => state.status[progress(actionType)] ? state.status[progress(actionType)] : undefined; export const errorListSelector = (actionType: string) => ( state: AppState ): any | undefined => state.status[errors(actionType)] ? state.status[errors(actionType)] : undefined; |