Answer the question
In order to leave comments, you need to log in
How to more optimally handle the error of getting an entity in state NGXS?
Let's say there is some state:
@State<Some>({
name: "some",
})
@Injectable()
export class SomeState {
constructor(
private readonly someService: SomeService) {
}
@Action(GetSomeAction)
getPage(ctx: StateContext<Some>, action: GetSomeAction) {
return this.someService.getSome(action.params).pipe(
catchError((error: HttpErrorResponse) => {
// так делать не хочется
ctx.dispatch(new SomeErrorAction(error));
return throwError(error);
}),
tap(res => {
// set state
})
);
}
}
@Select(SomeState) private readonly some$: Observable<Some>;
some$.subscribe(some=> this.onSomeLoad(some), err => // тут хочется обработать ошибку, но это не работает);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question