F
F
Furamy2021-03-22 11:58:01
Angular
Furamy, 2021-03-22 11:58:01

Why is ngrx swearing at my reducer?

I'm trying to implement the authentication state, but for some reason my reducer swears
auth.reducer.ts

import {AuthActions, authActionsType} from "./auth.actions";
import {ActionReducer} from "@ngrx/store";


export interface AuthState {
    authStatus: boolean
}

const initialState: AuthState = {
    authStatus: false
}

export const authReducer = (state = initialState, action: AuthActions) => {
    switch (action.type) {
        case authActionsType.signIn:
            return {
                ...state,
                authStatus: true
            }
        case authActionsType.logOut:
            return {
                ...state,
                authStatus: false
            }
        default:
            return state
    }
}

auth.actions.ts
import { Action } from '@ngrx/store'

export enum authActionsType {
    signIn = '[AUTH] sign in',
    logOut = '[AUTH] log out'
}

export class SignInAction implements Action {
    readonly type = authActionsType.signIn
}

export class LogOutAction implements Action {
    readonly type = authActionsType.logOut
}

export type AuthActions = SignInAction | LogOutAction

index.ts
import { Action, ActionReducerMap, MetaReducer } from '@ngrx/store'
import { environment } from '../../environments/environment'
import {authReducer, AuthState} from './auth/auth.reducer'


export interface State {
    auth: AuthState
}

export const reducers: ActionReducerMap<State> = {
    auth: authReducer
}

export const metaReducers: MetaReducer<State>[] = !environment.production
    ? []
    : []


Well, the error
60585bbde9da4538778837.jpeg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question