๐ Hello @ngrx/signals
Exciting news for Angular developers!
Exciting news for Angular developers!
With the release of Angular Signals, the NgRx team - especially Marko Stanimiroviฤ who came up with the idea and did the heavy lifting - built a new state management solution that provides a reactive state management solution and a set of utilities for Angular Signals.
@ngrx/signals consists of two big blocks and includes multiple smaller convenient Lego blocks to make working with state simple and intuitive.
- The
signalStateutility method provides a lightweight solution that manages state in a concise and minimalistic manner; - While
signalStoreprovides a full-blown state management solution (with optional plugins, e.g. Entity Management);
These tools provide an opinionated, but flexible, development experience to build your application.
Check out the v17 blog post for more info, or the in-depth blog posts from the Angular Architects team!
counter.component.tsimport { } from ;import { , } from ;@Component{:,:true,:,}exportclassCounterComponent{state=signalState{:0};increment(){patchStatethis.,(state)=>{:.+1};}decrement(){patchStatethis.,(state)=>{:.-1};}reset(){patchStatethis.,{:0};}}
counter.store.tsimport { } from ;import { } from ;import { } from ;import {,,,,,,} from ;exportconst=signalStorewithState{:0},withComputed({count})=>{:computed()=>count*2,},withMethods({count,...store})=>{increment(){patchState,{:count+1};},decrement(){patchState,{:count-1};},},withHooks{onInit({increment}){interval2_000.pipetakeUntilDestroyed.subscribe()=>increment;},onDestroy({count}){.log,count;},},;
counter.component.tsimport { , , } from ;import { } from ;@Component{:,:true,:,:,:.,}export default class CounterComponent {readonly store = inject;}
Feel free to update this developer bit on GitHub, thanks in advance!