Questions tagged [ngxs]

NGXS - Provides State Management for Angular apps based on a Event Sourcing model.

Questions about NGXS

The way we (the ngxs team) would prefer getting questions is on stackoverflow with the ngxs tag. And that we only post issues (bugs) to github.

By having questions on stackoverflow instead of the github issues, they don't get lost when we close the issue.

If you are unsure if your problem is bug or not, it's better to post it here on stackoverflow. The ngxs team monitors stackoverflow, and will try to answer your question as soon as possible, so you will have the same attention here.

You can also try joining our slack channel and ask your question there, but again I think it's better that we populate stackoverflow with the questions and answers as they are easily searchable and indexed by google.

541 questions
8
votes
3 answers

Ngxs - Call an Angular service : good practices?

When I use ngxs what should my app do: my component calls a service and the service dispatches an action with the result as the payload? my component dispatches an action and my State calls the service?
Vincent Nabet
  • 128
  • 1
  • 6
7
votes
3 answers

Error: export 'ɵivyEnabled' (imported as 'ɵivyEnabled') was not found in '@angular/core'

I've created a new Angular app (v15.2.0) and I've added @ngxs/store (v3.7.6) A detailed package.lock can be seen here { ... "dependencies": { "@angular/animations": "^15.2.0", "@angular/common": "^15.2.0", "@angular/compiler":…
skymeister
  • 73
  • 5
7
votes
1 answer

NGXS Error: Can't resolve all parameters for TranslationEditorState: (?)

I'm using NGXS for state management in Angular 9 application. In one of the state classes, any dependency injection causes an error "Error: Can't resolve all parameters for TranslationEditorState: (?)." I've tried injecting a service and even the…
Ashish Dwivedi
  • 149
  • 2
  • 11
7
votes
2 answers

Handling errors in NGXS (angular) with global error handler

I'd like to handle errors in NGXS in two ways. The first way is handling an error on the store dispatch in a component. The second way is a global angular error handler as a fallback for when the error is unhandled (not handled by first way). But…
cmart
  • 991
  • 3
  • 11
  • 19
7
votes
1 answer

Action logged but not triggered

I have a module with a component that dispatches a FETCH action, which gets the data from the API and then dispatches a RECEIVED action. It's working perfectly. Then I replicate the model, action and state to another module and component (with…
subarroca
  • 851
  • 7
  • 22
7
votes
2 answers

ngxs: Access different state within Action

Is it possible to access a different state within a action? Scenario: I have two states: FilterState AppState FilterState contains an action Filter, when the filter action is triggered, then the filterService is called with the payload of the…
Ratan
  • 603
  • 6
  • 19
6
votes
1 answer

Where to make API call and how to structure actions

I've recently started migrating from ngrx to ngxs and had a design question of where I should be placing some of my calls. In NGRX, I would create 3 actions for each interaction with an api. Something like: GetEntities - to indicate that the initial…
JakeHova
  • 1,189
  • 2
  • 15
  • 36
6
votes
2 answers

Angular 5: NGXS & route resolvers

Is it possible to user route resolvers with the NGXS store? I have a test made like this, but I don't know if it is the correct way to go: import {ActivatedRouteSnapshot, Resolve} from "@angular/router"; import {Todo} from "./todos.models"; import…
rauwebieten
  • 149
  • 7
6
votes
2 answers

Cleaner way of subscribing to the actions stream with NGXS

So I'm usually having a method that dispatches an action on click: create() { this.store.dispatch(new Create(this.form.value)); } this code triggers the following scenario and dispatches a CreateSuccess or CreateFailed depending of if the…
EinArzt
  • 347
  • 3
  • 11
6
votes
2 answers

Do something when an action has been dispatched

Let's say we an action SyncUserData, which returns observable that listen to changes from the database. Whenever there's a change, the action dispatches the action new PatchUserData(newData). The SyncUserData action is dispatched (only once) from…
Eliya Cohen
  • 10,716
  • 13
  • 59
  • 116
6
votes
3 answers

Ngxs - How do I chain actions?

I want to do something like this for my registration. When clicking the register button, this will be executed: this.store.dispatch(new Register(user)) .subscribe(response => { localStorage.setItem('token',…
Jonathan Lightbringer
  • 435
  • 2
  • 12
  • 27
6
votes
2 answers

Can we handle ngxs @Action errors via ofActionErrored() without going to default "ErrorHandler"?

I have an async ngxs action that throwsError(). I would like the default error handling mechanism to ignore this thrown error because I will be handling it in my code via ofActionErrored(). However, for other actions, default error handling should…
kctang
  • 10,894
  • 8
  • 44
  • 63
6
votes
2 answers

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

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()…
Abrkad
  • 243
  • 1
  • 3
  • 10
6
votes
1 answer

Why use NGRX instead of constructor injected services?

Wondering why one would use NGRX or NGXS for an Angular app instead of constructor injected services to handle component IO? Is it only to ensure that component properties references are never mutated without switching out the entire property value…
Ole
  • 41,793
  • 59
  • 191
  • 359
5
votes
2 answers

How to use Ngxs is a standalone component?

Is it possible to use Ngxs in a standalone component? I've tried importing the NgxsModule in the following ways: @Component({ ... imports: [ ... NgxsModule.forFeature([MyState]), ... and @Component({ ... imports: [ ... …
Jake Smith
  • 2,332
  • 1
  • 30
  • 68
1
2
3
36 37