ngrx / store

RxJS powered state management for Angular applications, inspired by Redux
MIT License
3.9k stars 311 forks source link

What exactly is a slice? #463

Open ocxler opened 7 years ago

ocxler commented 7 years ago

Hey, I am new to angular and especially ngrx, but I have built a working example with different components using ngrx/store (counter and chat). I understood so far, the application state is cut into different pieces of states, I have a state defined for the counter and a state for the chat, both together is the application state. In my components, I select the corresponding properties and everything works fine. My Question is: What exactly is a slice? Is it a selected part of properties of a state or is it an emitted update of a selected state? Hope somebody can explain it... Greetings Lukas Scheerer

laurelnaiad commented 7 years ago

In the one context the word is used in the docs, it's describing select, which is just distinctUntilChanged over a property (or function) over the observable object to which it is applied. In other words, if applied at root, it sees every single version of the state that comes into existence, and emits when its subject property (or function) yields a different value than it did the last time.

https://github.com/ngrx/core/blob/master/src/operator/select.ts