feat(reducers): Introduce unique id to reducer actions
This commit is contained in:
parent
231fd8bd53
commit
a5875b273f
|
@ -48,11 +48,6 @@ export function buildStoreChunk(name: string, structure: any, {
|
||||||
//at the top level. If the structure is a function (i.e. not nested reducers) then return
|
//at the top level. If the structure is a function (i.e. not nested reducers) then return
|
||||||
//the actions, and selectors as the top level of their respective objects.
|
//the actions, and selectors as the top level of their respective objects.
|
||||||
if (isFunction(structure)) {
|
if (isFunction(structure)) {
|
||||||
console.log(111, processedStructure, {
|
|
||||||
reducers: processedStructure.reducers,
|
|
||||||
actions: processedStructure.actions[name],
|
|
||||||
selectors: processedStructure.selectors[name],
|
|
||||||
});
|
|
||||||
return {
|
return {
|
||||||
reducers: processedStructure.reducers,
|
reducers: processedStructure.reducers,
|
||||||
actions: processedStructure.actions[name],
|
actions: processedStructure.actions[name],
|
||||||
|
|
|
@ -52,6 +52,9 @@ export const REDUCER_CREATOR_MAPPING: { [key: PropTypeKeys]: any } = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const createUniqueString = Math.random().toString(36).substring(7);
|
||||||
|
|
||||||
|
|
||||||
export function determineReducerType(reducerDescriptor: ReducerType, {
|
export function determineReducerType(reducerDescriptor: ReducerType, {
|
||||||
name,
|
name,
|
||||||
locationString,
|
locationString,
|
||||||
|
|
|
@ -134,11 +134,12 @@ export function createArrayReducer(arrayTypeDescription: ArrayStructureType, {
|
||||||
locationString,
|
locationString,
|
||||||
name,
|
name,
|
||||||
}: ArrayReducerOptions) {
|
}: ArrayReducerOptions) {
|
||||||
|
const uniqueId = Math.random().toString(36).substring(5);
|
||||||
return {
|
return {
|
||||||
reducers: {
|
reducers: {
|
||||||
[name]: createReducer(arrayTypeDescription, createReducerBehaviors(DEFAULT_ARRAY_BEHAVIORS, locationString))
|
[name]: createReducer(arrayTypeDescription, createReducerBehaviors(DEFAULT_ARRAY_BEHAVIORS, `${uniqueId}-${locationString}`))
|
||||||
},
|
},
|
||||||
actions: createActions(DEFAULT_ARRAY_BEHAVIORS, locationString, {}),
|
actions: createActions(DEFAULT_ARRAY_BEHAVIORS, `${uniqueId}-${locationString}`, {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,11 +81,12 @@ export function createShapeReducer(reducerShape: StructureType, {
|
||||||
locationString,
|
locationString,
|
||||||
name,
|
name,
|
||||||
}: ShapeReducerOptions) {
|
}: ShapeReducerOptions) {
|
||||||
|
const uniqueId = Math.random().toString(36).substring(5);
|
||||||
return {
|
return {
|
||||||
reducers: {
|
reducers: {
|
||||||
[name]: createReducer(reducerShape, createReducerBehaviors(DEFAULT_SHAPE_BEHAVIORS, locationString)),
|
[name]: createReducer(reducerShape, createReducerBehaviors(DEFAULT_SHAPE_BEHAVIORS, `${uniqueId}-${locationString}`)),
|
||||||
},
|
},
|
||||||
actions: createActions(DEFAULT_SHAPE_BEHAVIORS, locationString),
|
actions: createActions(DEFAULT_SHAPE_BEHAVIORS, `${uniqueId}-${locationString}`),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,11 +69,12 @@ export function createPrimitiveReducer(primitiveType: PrimitiveType, {
|
||||||
locationString,
|
locationString,
|
||||||
name,
|
name,
|
||||||
}: PrimitiveReducerOptions) {
|
}: PrimitiveReducerOptions) {
|
||||||
|
const uniqueId = Math.random().toString(36).substring(5);
|
||||||
return {
|
return {
|
||||||
reducers: {
|
reducers: {
|
||||||
[name]: createReducer(primitiveType, createReducerBehaviors(DEFAULT_PRIMITIVE_BEHAVIORS, locationString)),
|
[name]: createReducer(primitiveType, createReducerBehaviors(DEFAULT_PRIMITIVE_BEHAVIORS, `${uniqueId}-${locationString}`)),
|
||||||
},
|
},
|
||||||
actions: createActions(DEFAULT_PRIMITIVE_BEHAVIORS, locationString),
|
actions: createActions(DEFAULT_PRIMITIVE_BEHAVIORS, `${uniqueId}-${locationString}`),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue