UNPKG

fb-test-module

Version:

How to use: ``` import {store, getStore} from 'fb-test-module'; conf.DialogramApi = "API_BASE_URL"; conf.Platform = "mobile"; //use "web" if you are on webApp getStore(); //Inject store in your provider ``` and you'r readyt to go. # Base ## Act

22 lines (19 loc) 923 B
import Immutable, { fromJS } from 'immutable'; import { Status, SET_ENTITY } from './BaseType'; import { ActionType } from './BaseModel'; export function baseReducer(state, action: ActionType, entity: string) { switch (action.type) { case `${entity} ${SET_ENTITY}`: const merged = action.payload.data.get('includes').merge(action.payload.data.get('data')); return state.merge(merged); case `${entity} ${Status.Failure}`: return state.setIn(['status'], Status.Failure) .setIn(['error'], fromJS({ code: action.payload.data.code, message: action.payload.data.message })); case `${entity} ${Status.Loading}`: return state.setIn(['status'], Status.Loading); case `${entity} ${Status.Success}`: return state.setIn(['status'], Status.Success); default: return state; } }