NgRx 18 marks a major shift in the NgRx ecosystem — the SignalStore (introduced in NgRx 17) is now the primary recommendation for state management in Angular applications, while the classic NgRx Store remains fully supported for larger enterprise use cases.
// patchState now supports deeply nested partial updates
patchState(store, {
user: { address: { city: 'New York' } } // only city changes
});
import { withEntities, setAllEntities } from '@ngrx/signals/entities';
export const ProductStore = signalStore(
withState({ loading: false }),
withEntities<Product>(), // adds entities, ids, entityMap signals
withMethods((store) => ({
loadProducts: rxMethod<void>(pipe(
switchMap(() => productService.getAll()),
tap(products => patchState(store, setAllEntities(products)))
)),
}))
);
All Comments