Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[API_SET_HEADER]: (state, { payload: header }) => {
const newState = imm(state);
Object.keys(header).forEach(key => {
newState.set(['endpoint', 'headers', key], header[key]);
});
return newState.value();
},
[API_WILL_CREATE]: (state) => {
return imm(state).set(['isCreating'], state.isCreating + 1).value();
},
export const mergeResources = (state, { data, included = [] }) => {
const newState = imm(state);
resourcesArray(data).concat(included).forEach((dataObj) => {
const { id, type } = dataObj;
newState.set(['resources', type, String(id)], dataObj);
createReverseRelationships(state, newState, dataObj);
});
return newState.value();
};
.add('object-path-immutable', () => {
immutableO(obj).set('createUser.data.post.create.title', 'String')
})
.add('immutable', () => {
[API_READ]: (state, { payload }) => {
const resources = (
Array.isArray(payload.data)
? payload.data
: [payload.data]
).concat(payload.included || []);
const newState = updateOrInsertResourcesIntoState(state, resources);
const finalState = addLinksToState(newState, payload.links, payload.options);
return imm(finalState)
.set('isReading', state.isReading - 1)
.value();
},