In our application we have these codes
export function compose<T>(
initial: T,
tasks: { [name: string]: (state: T, payload?: any) => void },
copy = CopyStrategy.json
) {
return (state: T = initial || <T>{}, action: any) => {
let reply = null;
const task = tasks[action.type];
if (task) { task(reply, action.payload); }
return reply;
};
}
and this is how it's used
export const timeSheetReducer = compose<TimeSheetState>(timeSheetInitial, {
['timehsheet']: (state, payload) => {
....
},
['timehsheetSetStatus']: (state, payload) => {
....
}
},
I don't understand this part tasks: { [name: string]: (state: T, payload?: any) => void }, what does [ and ] means there and in it's usage too