ngxs

Actions/state to load data from backend

匆匆过客 提交于 2019-12-03 18:40:39
问题 I've just started experimenting with ngxs but from my reading so far I'm not 100% clear on where I should be calling back to my API to persist and read data (all examples I've seen are either not doing it, or using some mock). E.g. I've created a state where I maintain a list of items. When I want to add an item, I dispatch the 'AddItem` action to the store, where I add that new item to the state. This all works ok - the question is where is the appropriate place to plug in the call that

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

How to return a `forkJoin` observable when piping the operators

主宰稳场 提交于 2019-12-01 06:50:05
Before I had this resolver that just worked fine: resolve() { return forkJoin( this.getData1(), this.getData2(), this.getData3() ); } Now I have to do something like that which is actually does not work: resolve() { return this.actions$ .pipe( ofActionSuccessful(SomeSctonSuccess), forkJoin( this.getData1(), this.getData2(), this.getData3() ) ); } as I am hitting this error: Argument of type 'Observable<[any, any, any, any]>' is not assignable to parameter of type 'OperatorFunction'. Type 'Observable<[any, any, any, any]>' provides no match for the signature '(source: Observable): Observable'.

How to return a `forkJoin` observable when piping the operators

我们两清 提交于 2019-12-01 06:06:41
问题 Before I had this resolver that just worked fine: resolve() { return forkJoin( this.getData1(), this.getData2(), this.getData3() ); } Now I have to do something like that which is actually does not work: resolve() { return this.actions$ .pipe( ofActionSuccessful(SomeSctonSuccess), forkJoin( this.getData1(), this.getData2(), this.getData3() ) ); } as I am hitting this error: Argument of type 'Observable<[any, any, any, any]>' is not assignable to parameter of type 'OperatorFunction'. Type

Ngxs - Actions/state to load data from backend

喜欢而已 提交于 2019-11-30 00:27:35
I've just started experimenting with ngxs but from my reading so far I'm not 100% clear on where I should be calling back to my API to persist and read data (all examples I've seen are either not doing it, or using some mock). E.g. I've created a state where I maintain a list of items. When I want to add an item, I dispatch the 'AddItem` action to the store, where I add that new item to the state. This all works ok - the question is where is the appropriate place to plug in the call that POSTs the item to the server? Should I call the API in my action implementation i.e. just before I update

Http requests made from Ngxs state doesn't get detected by Angular (zone related issue)

会有一股神秘感。 提交于 2019-11-29 18:09:44
I'm using ngx-progressbar and it works fine with http request started from within services, components or resolvers. Note that no manual triggering of the progress bar (via service, etc) during http request is needed. It is triggered automatically. Unfortunately it doesn't work as expected when making an http request from within an NGXS State : stackblitz : I created for every case a button : "Make Request (Dispatch to store, w/o zone)" This does not work, no progress bar appears (or it appears but hangs and does not complete to 100%) @Action(LoadUrl) load({ setState }: StateContext<string>) {