State management in Angular is often over-engineered. Do you really need the full Redux pattern (NgRx) with its boilerplate Actions, Reducers, Effects, and Selectors? Or is Akita’s OO-approach better?
NgRx: The Strict Pure Approach
NgRx is verbose but predictable. It shines in large teams where strict enforcement of “One Way Data Flow” prevents spaghetti code.
createAction('[Auth] Login Success', props<{ user: User }>());
on(AuthActions.loginSuccess, (state, { user }) => ({ ...state, user }));
Akita: The Pragmatic Approach
Akita uses efficient Stores and Queries. It feels like working with a database.
@Injectable({ providedIn: 'root' })
export class SessionStore extends Store<SessionState> {
constructor() { super({ user: null }); }
updateUser(user: User) {
this.update({ user });
}
}
For 80% of applications, Akita (or Elf) provides significantly higher developer velocity with 90% of the benefits of NgRx.
Discover more from C4: Container, Code, Cloud & Context
Subscribe to get the latest posts sent to your email.