I have a state which contains an array of data. I need to remove all data from that array when certain action done. I use Angular 2.
const intialState: State = {
someData: new Array<someData>()
};
export function stateReducer(state = intialState, action: StateActionList.StateActionList) {
switch (action.type) {
case StateActionList.REMOVE_DATA:
console.log(state.someData);
return {
...state,
someData: new Array<someData>()
}
}
}
In my component I have following code:
this.store.dispatch(new StateActions.RemoveData());
In State actions:
export const REMOVE_DATA="REMOVE_DATA";
export class RemoveData implements Action {
readonly type=REMOVE_DATA;
}
That code doen't return for me cleaned array someData from the store. The array contains same data as it was before