Questions tagged [ngxs]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
7 views

NGXS how to access setState and patchState without the ctx argument?

I'm trying to refactor my state by creating a reusable function that handles a patch. How can I access setState and patchState without this strange context argument? updateThings(ctx: StateContext<...
Ben Racicot's user avatar
  • 5,249
0 votes
0 answers
13 views

Doesn't support angular-ru/ngxs with Angular v16

I installed angular-ru/ngxs. but I cannot import any thing from package, it shows "Cannot find module '@angular-ru/ngxs' or its corresponding type declarations." this is my package.json ...
pragith98's user avatar
1 vote
0 answers
13 views

NGXS iif Expected 2 type arguments, but got 1 error

I'm getting an unexplainable error with NGXS' iif operator. I've copy and pasted this update patch because its what I built for an exact duplicate table data setup in the same project. However, this ...
Ben Racicot's user avatar
  • 5,249
0 votes
0 answers
61 views

TypeScript 4.9.5 Upgrade Causing Type Inference Issue with Generic Interfaces

I have a somehow strange problem with typescript I don't understand. The compiler error occurs since I upgraded typescript to version 4.9.5 from 4.6.4. I have the impression that it should compile but ...
Hans Dabi's user avatar
  • 159
0 votes
1 answer
32 views

Ngxs @Select decorator returns undefined even after subscription

I am trying to read the labels that are saved in the state. Below is my state file export class LabelStateModel { labels: LabelConfig = {}; } @State<LabelStateModel>({ name: 'labels', ...
Shah Rukh's user avatar
  • 291
0 votes
0 answers
15 views

NGXS - defaults being optional values breaking state's model typing?

I a quick question on defaults values, as it's making me a bit confused. Why is defaults value on the state optional? Wouldn't it mess up the typing and create many runtime errors if we forget to set ...
Mick412's user avatar
  • 55
0 votes
0 answers
41 views

How to cancel a previous HTTP call using switchMap without a source observable?

I've been trying to think of a good way to cancel previous HTTP request when new requests are fired, for which I would normally use the switchMap operator. However, due to my request being not bound ...
Heribert Greinix's user avatar
0 votes
0 answers
168 views

Cannot access before initialization - Angular NGXS

I am using Angular application with state management as NGXS, I have used a selector to get data from the store, in which I have used the reference of other state to get data based on conditions. In ...
Anjali Thakkar's user avatar
1 vote
0 answers
70 views

How to apply default theme to ngx-mat-datetime-picker?

I'm using Angular 15, but somehow the ngx-mat-datetime-picker styling got disturbed; I'm not able to see which date has been selected while clicking on the calendar date, but functionality-wise, it's ...
Sumit's user avatar
  • 11
0 votes
1 answer
24 views

Type 'UserStateModel' does not satisfy the constraint 'Record<string, any>'

I do have an angular 15 App with NGXS as state management framework. All works fine, even the method i post as a problematic here was working find and the error occurred without any manipulation on my ...
jorkata's user avatar
  • 11
1 vote
0 answers
104 views

NgxsModule.forRoot([]) in child module (instead of app.module.ts)

I am trying to use Ngxs only in one of my components in application. When I import NgxsModule.forRoot([]) in my child module where I will be using it I'm getting this error and whole application is ...
joanna's user avatar
  • 11
3 votes
1 answer
148 views

NGXS : cannot pass objects to "setState" when one of the patched inner fields is nullable or undefined

I have this class meant for storing a state in my angular components: export class MyStateModel { subState1: SubStateModel1; substate2: SubStateModel2; } It contains simple subclasses : export ...
jeancallisti's user avatar
  • 1,076
0 votes
1 answer
232 views

Ngxs Select Decorator return undefined value

The select decorator is always return undefined. I have below state defined. @State<ISidebarState>({ name: 'sidebar', defaults: { moduleWidgetSidebarState: 'close', ...
Imrankhan Pathan's user avatar
1 vote
1 answer
327 views

NgxsFeatureModule does not have a module def (ɵmod property)

Running NX mono repo and Angular "@nrwl/angular": "15.2.4", "@angular/core": "~15.0.0", "@ngxs/store": "^3.7.6", "jest": "28....
HADI's user avatar
  • 2,829
7 votes
3 answers
2k views

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": "^...
skymeister's user avatar
0 votes
1 answer
228 views

NGXS - Handle Observable Side-Effect from Action

I have a NGXS action that triggers a side-effect. The side-effect gets a list of todos as an Observable stream (e.g. firestore collection). Depending on the success or failure, the side-effect will ...
Nocebo's user avatar
  • 1,927
3 votes
1 answer
640 views

ionic - ngxs failed to implement

I created a complete new ionic project with ionic start. And then i added ngxs like so npm install @ngxs/store --save. But i have an error, when starting the app. I implemented also the store in app....
Jonathan Sigg's user avatar
0 votes
1 answer
65 views

Mock a specific ngxs store select with ngxs

In the component there are two ngxs selectors: @Component({ selector: 'some-componet', templateUrl: './some-componet.html', styleUrls: ['./some-componet.scss'], changeDetection: ...
Remi's user avatar
  • 4,735
0 votes
2 answers
2k views

'NgxsRootModule' does not appear to be an NgModule class

I am trying to learn NGXS and, therefore, following a tutorial. The tutorial said to install ngxs store and other dependencies, and I did with: npm install @ngxs/store --save; npm i @ngxs/logger-...
igryn's user avatar
  • 13
0 votes
1 answer
69 views

Error 6412 - Cannot assign to read only property

I am trying to update the state model, but I am running into an issue (because I do not have enough experience with it yet). Getting "core.mjs:6412 ERROR TypeError: Cannot assign to read only ...
Devon St. Denis - Richard's user avatar
0 votes
1 answer
136 views

NGXS using an Observable output to dispatch actions

In the case where I have an observable that could periodically emit new values (Timer, SignalR, etc), is there a better way to dispatch NGXS actions besides calling store.dispatch() from the ....
aasukisuki's user avatar
  • 1,186
0 votes
1 answer
41 views

NGXS typed raw state value

I cannot find an example in the NGXS documentation on how to type the state object. I want to type the return value of the snapshot method of Store. For example this.store.snapshot().SOME_STATE_SLICE ...
Thabo's user avatar
  • 1,303
1 vote
1 answer
87 views

ReferenceError when I try to execute unit test using jest over a NGXS service facade [angular]

I am trying to write some test in jest for a NGXS implementation, but in all the places where I am using the store, I am receiving the next error: ReferenceError: auth_models_1 is not defined ...
Oscar Andres PAbon's user avatar
0 votes
1 answer
88 views

NGXS Store Custom Logic with RXJS before Rendering

I am currently trying to display a variable from my NGXS store dynamically in the frontend. This is usually no problem using the async pipe, but when I try to add logic the application freezes. I have ...
Marcel Rückert's user avatar
0 votes
0 answers
47 views

NGXS multiple sub states update from same async action

I have a parent-child states that manage reports and documents respectively. When a report is submitted, I need to store the user posted data for the report and the async action returned id in the ...
Oskar Cermeño's user avatar
0 votes
1 answer
108 views

NGXS Selectors bug or am i losing my mind?

@Selector() static broken(state: AuthStateModel): string | null { return state.token; } @Selector() static token(state: AuthStateModel): string | null { return state.token; ...
Sekula's user avatar
  • 13
1 vote
1 answer
223 views

NGXS State Changed Event

I have an NGXS store that contains (lets say) an object. obj = { name: 'so-and-so', age: 42, nationality: 'country-name', address: { ... } }. When I update any of the properties (even nested propeties,...
ashutosh_paul's user avatar
2 votes
1 answer
194 views

Jasmine withArgs expected types

I have been going through and upgrading my angular version from 10 to 13. So that I could use typescript 4.6. In doing this, I screwed up some types in my tests and was curious if anyone else has ...
Brendan Murphy's user avatar
0 votes
1 answer
212 views

How should NgxsModule.forRoot()/NgxsModule.forFeature() be used?

I have a main app.module.ts in my project, as well as several modules for different features, such as archive.module.ts. I use local storage to restore certain settings on page refresh, so I also use ...
kassfb's user avatar
  • 13
0 votes
1 answer
43 views

HTML compilation gets blocked by forbidden 'null' data type, even though null can't be a value

I've got a problem with my HTML code, where the compiler dies on: Type 'CustomItem[] | null | undefined' is not assignable to type 'CustomItem[] | undefined'. Type 'null' is not assignable to type '...
Heribert Greinix's user avatar
0 votes
1 answer
303 views

Ngx-Captcha issue

I am using https://www.npmjs.com/package/ngx-captcha/v/11.0.0. <ngx-recaptcha2 #captchaElem [siteKey]="'6Leh1ZIjAAAAAG8g0BuncTRT-VMjh3Y7HblZ9XSZ'" (success)="handleSuccess($event)&...
jayanti khutwad's user avatar
0 votes
0 answers
66 views

How to test action's dispatching in ngxs?

I try to cover @Action with unit tests and had some difficulties. Here is an action example: @Action(ActionsList.SetId) public SetId(ctx: StateContext<DbModel>): Observable<string[]> { ...
Toxa26's user avatar
  • 3
0 votes
0 answers
52 views

While migrating project to angular 13 i get this Error: Type NgxsFeaturesModule does not have emod property

The above error is occurring on a specific scenario and that is When i run the project and select google bot as user agent in network condition tab of browser and refresh the page. I am implementing ...
Ravi's user avatar
  • 1
0 votes
0 answers
41 views

How can I test the ng Zorro modal?

deleteThing(id: RecordModel['id']): void { this.modalService.confirm({ nzTitle: this.translateService.instant("confirm.delete-thing.title"), nzContent: this.translateService....
Nikita Ivanov's user avatar
1 vote
1 answer
84 views

Why old data persists in component and how can I reset it

I fetch data in NGXS state @State<CollectionsStateModel>({ name: 'collections', defaults: { collectionList: [], (...), isListLoading: true, }, }) @Selector() static collectionList(state: ...
MrOwl's user avatar
  • 69
1 vote
1 answer
220 views

How can I get paramMap of ActivatedRoute inside ngxs state

I need to update my ngxs state depending on different navigation routs, but when I use constructor(private route: ActivatedRoute) {} in the constructor in the state and try to use it inside the ...
MrOwl's user avatar
  • 69
2 votes
0 answers
238 views

Horizontal NGX Slider goes crazy up and down without stopping in 2.0.4. version

Hello i am using ngx slider <ngx-slider [(ngModel)]="my_pointsNew" (userChange)="onUserChange($event)" [(value)]="verticalSlider3.my_pointsNew" [options]="...
SimonIoa's user avatar
  • 127
0 votes
0 answers
143 views

How to mock NGXS Select with ng-mock Angular

Im using NGXS store for my Angular project and ng-mock for unit testing. I'm wondering how to deal with NGXS '@Select' when testing? My Component TS import { Component } from '@angular/core'; import { ...
Kaloyan Stamatov's user avatar
0 votes
0 answers
117 views

Connecting NGXS in Angular to socket.io websocket server

Short story: I am trying to connect to my custom websocket server using NGXS. Using a default websocket implementation it works fine. But... I kinda want to implement socket.io on the server side ...
Emphy's user avatar
  • 11
0 votes
0 answers
16 views

Angular unit test with Ngxs fails only partly

Making unit tests for Angular and upon testing interaction with the state the tests keep failing fdescribe('MarketplaceComponent', () => { let component: MarketplaceComponent; let fixture: ...
Janjac's user avatar
  • 90
0 votes
1 answer
31 views

How to slice parts of an array if the array has to many elements in NGXS Devtools?

I have an array in my state with around 1500 elements. I realized that the Angular application is lagging if I dont disable the NGXS Devtools because of the large array. Now I want to either dont show ...
Invader's user avatar
  • 141
5 votes
2 answers
2k views

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 ...
Jake Smith's user avatar
  • 2,332
0 votes
0 answers
126 views

Shared NGXS state/action issue with NX in Cypress

I am having the following scenario: NX with common app, app1 and app2. NGXS with app1-state, app2-state and a common state. So that app1 invokes action from app2 and app2 updates common state. App1 ...
user1781328's user avatar
1 vote
1 answer
41 views

Are ngXS selectors fired on the page init, without any changes of the state slice that returned?

I have a selector and I subscribe to them on ngOnInit; but the code inside the subscribe is executed every time when the page is initialized (refreshed). @Select(SurveysSelectors.deleteSurveys) ...
Alin's user avatar
  • 13
1 vote
0 answers
538 views

NGXS ERROR NullInjectorError: R3InjectorError(SignUpModule)[Store -> Store -> Store -> Store -> Store]

I have a structure like this: AuthenticationModule SignInModule SignUpModule and each module has its own component. The problem is that in SignUpComponent, I cannot inject Store from ngxs. But in ...
Jean-Paul Abi-Ghosn's user avatar
1 vote
1 answer
272 views

How to combine two dynamic selectors to a new selector?

I have the following selector static orderFilteredByStatus(status: string){ return createSelector([OrderState], (state: OrderStateModel) => {...} } Now I have another selector in a different ...
Invader's user avatar
  • 141
1 vote
0 answers
84 views

How to store error statues and messages in NGXS?

This might be a somewhat open question, but I has to do with best practices when using NGXS. I was wondering which approach would be best for error handling and what to keep in each State in a typical ...
gnc's user avatar
  • 41
0 votes
0 answers
37 views

Can synchronous part of async method be interupted by another thread

I'm creating an Action handler in NgXS (state management using NgRx under the hood). Assuming that the action will be dispatched multiple times in short time period - is there a chance that more than ...
Jakub Biernaczyk's user avatar
0 votes
0 answers
127 views

Combining ngxs/forms with @ngxs/storage-plugin causes ExpressionChangedAfterItHasBeenCheckedError when ngxs swaps values on init

When a page contains a form connected to the store via @ngxs/form-plugin and this store is cached using @ngxs/storage-plugin, I get ExpressionChangedAfterItHasBeenCheckedError if I use the angular ...
Ilya Konrad's user avatar
0 votes
0 answers
44 views

Ngxs getState() after setState() returns empty always

Building state with ngxs in angular //Component.ts ngOnInit(): void { const dataInsdeStore = this.store.selectSnapshot(MarketState); if(!dataInsdeStore.loaded){ const category = this....
Janjac's user avatar
  • 90

1
2 3 4 5
11