Some actions will affect the entire kepler.lg instance state.
The updaters for these actions is exported as combinedUpdaters. These updater take the entire instance state
as the first argument. Read more about Using updaters
Examples
import keplerGlReducer, {combinedUpdaters} from 'kepler.gl/reducers';
// Root Reducer
const reducers = combineReducers({
keplerGl: keplerGlReducer,
app: appReducer
});
const composedReducer = (state, action) => {
switch (action.type) {
// add data to map after receiving data from remote sources
case 'LOAD_REMOTE_RESOURCE_SUCCESS':
return {
...state,
keplerGl: {
...state.keplerGl,
// pass in kepler.gl instance state to combinedUpdaters
map: combinedUpdaters.addDataToMapUpdater(
state.keplerGl.map,
{
payload: {
datasets: action.datasets,
options: {readOnly: true},
config: action.config
}
}
)
}
};
}
return reducers(state, action);
};
export default composedReducer;Combine data and full configuration update in a single action
- Action:
addDataToMap
Parameters
stateObject kepler.gl instance state, containing all subreducer stateactionObjectaction.payloadObject{datasets, options, config}action.payload.datasets(Array<Object> | Object) *required datasets can be a dataset or an array of datasets Each dataset object needs to haveinfoanddataproperty.action.payload.optionsObject option object{centerMap: true}action.payload.configObject map config
Returns Object nextState