angular-state-managmement

How to use patchState vs setState in NGXS?

て烟熏妆下的殇ゞ 提交于 2019-12-14 00:18:41
问题 I am learning ngxs but I can't understand when should I use patchState and setState ? What's the difference? const state = ctx.getState(); let data = this.service.list(); ctx.setState({ ...state, feedAnimals: data }); vs. let data = this.service.list(); ctx.patchState({ feedAnimals: data }); 回答1: Those two pieces of code are equivalent. patchState is just a short hand version of the setState({...state, ... } code. In future patchState will most likely be evolving to a more useful immutability

Searching Data From Different Component in Angular NGXS

ε祈祈猫儿з 提交于 2019-12-02 04:40:18
问题 I'm trying to figure out how will i able to search in NGXS from different component. I have my searchbar from the navbar component while i'm displaying my data from app component which is a different component. Please see this stackblitz link CLICK HERE CODE this.peopleForm.get('name').valueChanges.pipe(debounceTime(500)).subscribe( (name: string) => { console.log(name); this.people$ = this.store.select(AppState.nameFilter(name)); } ) 回答1: Having a look at your StackBlitz, it seems you are

Searching Data From Different Component in Angular NGXS

帅比萌擦擦* 提交于 2019-12-02 01:22:25
I'm trying to figure out how will i able to search in NGXS from different component. I have my searchbar from the navbar component while i'm displaying my data from app component which is a different component. Please see this stackblitz link CLICK HERE CODE this.peopleForm.get('name').valueChanges.pipe(debounceTime(500)).subscribe( (name: string) => { console.log(name); this.people$ = this.store.select(AppState.nameFilter(name)); } ) Having a look at your StackBlitz, it seems you are trying to filter a list based on what is entered in the peopleForm input element. Rather than tryring to