Cancellation
Basic
import { Injectable } from '@angular/core';
import { State, Action } from '@ngxs/store';
@State<ZooStateModel>({
defaults: {
animals: []
}
})
@Injectable()
export class ZooState {
constructor(private animalService: AnimalService, private actions$: Actions) {}
@Action(FeedAnimals, { cancelUncompleted: true })
get(ctx: StateContext<ZooStateModel>, action: FeedAnimals) {
return this.animalService.get(action.payload).pipe(
tap((res) => ctx.setState(res))
));
}
}Using AbortSignal
Why AbortSignal?
With Async/Await
With Fetch API
With Observables
Advanced
Last updated

