I find Redux to be a very impressive library, and I am quite fond of it. However, I am facing an issue where actions are being called twice. What are some common mistakes that could be causing this behavior? Please note that I have already unsubscribed the subscription in the controller.
constructor(private _store: Store<AppState>) {
this.subscription = this._store.select('reduxObj').subscribe(function (item) {
switch (item.type) {
case fromAction.GETITEMS: {
break;
}
}
}.bind(this));
}
ngOnDestroy() {
this.subscription.unsubscribe();
}
ngOnInit() {
this._store.dispatch(new fromAction.GetListAction());
}
//REDUCER
export function ReduxReducer(state: any = undefined, action: fromAction.actions) {
switch (action.type) {
case fromAction.GETITEMS: {
return { ...state, type: fromAction.GETITEMS }
}
}
//ACTION
export class GetListAction implements Action {
readonly type = GETITEMS;
constructor() { }
}