Questions tagged [angular-state-managmement]

51 questions
22
votes
2 answers

How to use patchState vs setState in NGXS?

I am learning ngxs but I can't understand when should I use patchState and setState? What's the difference? const state = ctx.getState(); let data = this.service.list(); ctx.setState({ ...state, feedAnimals: data }); vs. let data = …
5
votes
1 answer

Why are Akita Queries accessed directly in components

I am learning Akita to add state management to an Angular application. When looking at the architecture diagram in the Akita documentation and examples such as this one on the Akita GitHub repo I see that the Query is accessed directly in…
Sam Herrmann
  • 6,293
  • 4
  • 31
  • 50
3
votes
2 answers

Angular 9 how to keep component state after back to previous page?

I am new to Angular. I am using Router for switch the screen.. Like this this._router.navigate(['a_page'],{state: {data: moredata}) and get the state in a_page constructor like this this._router.getCurrentNavigation().extras.state; But if i back…
Sabish.M
  • 2,022
  • 16
  • 34
3
votes
3 answers

Access Nested Object Inside Array in Angular NGXS

I have successfully implemented the delete comment function in my Angular app. My problem now is on the liking function of the comment. How do i implement the like function. I have the variable is_liked to determine if its like or not. The value = 0…
Joseph
  • 7,042
  • 23
  • 83
  • 181
3
votes
3 answers

Run a function on matched URL in Angular NGXS

Is there a way to run a function when matched a specific URL. For example: If i matched a URL "/home". Would it possible to run this action this.store.dispatch(new SampleAction())
user8305745
3
votes
1 answer

mobx & mobx-angular : how to update & subscribe to updated value from store?

I have angular app v6 and I'm using latest version of mobx and mobx-angular (You can see in dependency). I'm coming from ngrx, ngxs background so it is tough to understand mobx flow because it more or less angular-service approach with something…
micronyks
  • 54,797
  • 15
  • 112
  • 146
2
votes
0 answers

NGRX Feature state (slice) in standalone components without providers in route config

Need help, is there any way to create feature slices for ngrx state without putting in route block for standalone components. previously we have NgModule approach to achieve the same. @NgModule({ declarations: [ ], imports: [ …
2
votes
1 answer

NGXS global state's slices emit on every navigation

After tracking down unexpected requests being made I've found that my app's global user state's slices emit upon every navigation. What are potential causes of an NGXS state slice emitting where its data hasn't changed and actions have not been…
Ben Racicot
  • 5,332
  • 12
  • 66
  • 130
2
votes
1 answer

Angular NGXS don't recalculate selectors unless the selected data is updated in state

I have a NGXS state defined as below export interface Project{ _id:string, name:string } export class ProjectStateModel { projects: Project[]; } @State({ name: 'Projects', defaults: { projects:…
BiJ
  • 1,639
  • 5
  • 24
  • 55
2
votes
1 answer

How to remove data from array list - NGXS state management

I had a problem while trying NGXS state management, the problem is if I delete the record from the array using id, then the entire array getting empty. this is my user state looks like. @State({ name: "users", defaults: { …
Raheem Mohamed
  • 789
  • 3
  • 6
  • 15
2
votes
1 answer

Deleting an object of a nested data in Angular using NGXS

I have successfully implemented the get and delete function of post in my Angular app. My problem comes when you wanted to delete a comment inside a post. I'm trying to achieve it using NGXS. How will i be able to access it inside of the post so i…
Joseph
  • 7,042
  • 23
  • 83
  • 181
2
votes
1 answer

Angular re-renders list of components when state is changed without mutation

I am coming from React and I've been working with Angular for a few months now. A React component updates only the necessary HTML when is re-rendered, while an Angular component seems to re-render completely when the state is not mutated. If I…
Sergiu
  • 1,397
  • 1
  • 18
  • 33
2
votes
1 answer

Huge number of actions / effects for specific entity

As an angular application I am working on approaches medium to large size, so does the number of actions, and therefore effects, grow. How does one handle the growing action / effect files for specific entity. I have tried to separate actions into…
1
vote
1 answer

ngrx EntityState.ids.includes() expects parameter with type never

I have an Ionic Angular project with ngrx State management. Here is my State definition: export interface State { loaded: boolean; loading: boolean; invoices: InvoicesState; invoicePositions: InvoicePositionsState; selectedInvoice:…
1
vote
1 answer

Angular data sharing architecture

I feel like I fundamentally misunderstand one part of Angular, imagine the following: You have a navbar component which shows the logged in user, something like: then you have a user-edit…
1
2 3 4