<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: siddheshthipse</title>
    <description>The latest articles on Forem by siddheshthipse (@siddheshthipse).</description>
    <link>https://forem.com/siddheshthipse</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F681166%2Fef8cafbf-50dd-48cb-a546-2cbc7ab5c90c.jpeg</url>
      <title>Forem: siddheshthipse</title>
      <link>https://forem.com/siddheshthipse</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/siddheshthipse"/>
    <language>en</language>
    <item>
      <title>Beginner's guide to State Management using NGXS</title>
      <dc:creator>siddheshthipse</dc:creator>
      <pubDate>Thu, 19 Aug 2021 12:48:34 +0000</pubDate>
      <link>https://forem.com/siddheshthipse/beginner-s-guide-of-state-management-using-ngxs-35dn</link>
      <guid>https://forem.com/siddheshthipse/beginner-s-guide-of-state-management-using-ngxs-35dn</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;NGXS is a state management pattern + library for Angular. &lt;/p&gt;

&lt;p&gt;It acts as a single source of truth for your application's state, providing simple rules for predictable state mutations.&lt;/p&gt;

&lt;p&gt;NGXS is modeled after the CQRS pattern popularly implemented in libraries like Redux and NgRx but reduces boilerplate by using modern TypeScript features such as classes and decorators.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Getting started with NGXS as a beginner can be daunting, not because it is some kind of rocket science but essentially due to the fact that not many resources are available to learn it in a right way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjg9lyhjajpvpk5pem3tb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjg9lyhjajpvpk5pem3tb.png" alt="Block Schematic of NGXS" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial, we will use Angular along with NGXS to create a simple CRUD application consuming dummy REST APIs. &lt;/p&gt;

&lt;p&gt;If you're running out of patience already you can hop onto &lt;a href="https://stackblitz.com/github/siddheshthipse/learning-ngxs" rel="noopener noreferrer"&gt;StackBlitz&lt;/a&gt; and see for yourself what we're gonna do.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prerequisites
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Basic knowledge of Angular 2+ is must.&lt;/li&gt;
&lt;li&gt;Prior knowledge of RxJS would be helpful but isn't absolutely necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  So let's get started
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Step 1: Install Angular CLI
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;npm install -g @angular/cli&lt;/code&gt;&lt;br&gt;
OR&lt;br&gt;
&lt;code&gt;yarn add global @angular/cli&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a new Angular project, let's call it 'learning-ngxs'&lt;br&gt;
&lt;code&gt;ng new learning-ngxs&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 2: Install NGXS library
&lt;/h4&gt;

&lt;p&gt;First go to the project folder&lt;br&gt;
&lt;code&gt;cd learning-ngxs&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then enter this command&lt;br&gt;
&lt;code&gt;npm install @ngxs/store --save&lt;/code&gt;&lt;br&gt;
or if you're using yarn&lt;br&gt;
&lt;code&gt;yarn add @ngxs/store&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 3: Installing Plugins(optional)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Although this step is optional, I would highly recommend you to go through it since Logger and Devtools are the two extremely handy dev dependencies. &lt;/li&gt;
&lt;li&gt;These plugins help us in tracking the changes our state goes through.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For installing Logger and Devtools plugins fire the commands &lt;code&gt;@ngxs/logger-plugin --save&lt;/code&gt; &amp;amp; &lt;code&gt;@ngxs/devtools-plugin --save-dev&lt;/code&gt; respectively.&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 4: Importing Modules
&lt;/h4&gt;

&lt;p&gt;This is how your &lt;code&gt;app.module.ts&lt;/code&gt; file will look after importing the necessary modules&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {HttpClientModule} from '@angular/common/http';
import {FormsModule,ReactiveFormsModule} from '@angular/forms';
//For NGXS
import { NgxsModule } from '@ngxs/store';
import { NgxsLoggerPluginModule } from '@ngxs/logger-plugin';
import { NgxsReduxDevtoolsPluginModule } from '@ngxs/devtools-plugin';


import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { GeneralComponent } from './general/general.component';
import { AppState } from './states/app.state';
import { DesignutilityService } from './designutility.service';

@NgModule({
  declarations: [
    AppComponent,
    GeneralComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    FormsModule,
    ReactiveFormsModule,

    NgxsModule.forRoot([]), NgxsLoggerPluginModule.forRoot(), NgxsReduxDevtoolsPluginModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 5: Creating Components and Services
&lt;/h4&gt;

&lt;p&gt;Let's create a component say 'general' for displaying the contents of our state&lt;br&gt;
&lt;code&gt;ng g c general&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a service called 'designutility' for interacting with the server to &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; the data.&lt;br&gt;
&lt;code&gt;ng g s designutility&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Do not forget to add &lt;code&gt;DesignutilityService&lt;/code&gt; inside the &lt;code&gt;providers&lt;/code&gt; array in &lt;code&gt;app.module.ts&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;providers: [DesignutilityService]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure that you've imported all the modules mentioned in Step 4.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 6: Creating Actions
&lt;/h4&gt;

&lt;p&gt;Create a new folder named 'actions' inside src&amp;gt;app&lt;br&gt;
Inside the actions folder, create a new file named &lt;code&gt;app.action.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Here we define four actions for CRUD operations respectively

//Read
export class GetUsers {
    static readonly type = '[Users] Fetch';
}

//Create
export class AddUsers {
    static readonly type = '[Users] Add';
    constructor(public payload: any) { }
}

//Update
export class UpdateUsers {
    static readonly type = '[Users] Update';
    constructor(public payload: any, public id: number, public i:number) { }
}

//Delete
export class DeleteUsers {
    static readonly type = '[Users] Delete';
    constructor(public id: number) { }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Actions can either be thought of as a command which should trigger something to happen, or as the resulting event of something that has already happened.&lt;/p&gt;

&lt;p&gt;Each action contains a type field which is its unique identifier.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Actions are dispatched from the components to make the desirable changes to the State.&lt;/p&gt;

&lt;p&gt;You might have noticed that except for &lt;code&gt;GetUsers&lt;/code&gt;, in all other actions we have a parameterized constructor.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;These parameters are nothing but the data which would be coming from various components whenever the action is dispatched.&lt;/li&gt;
&lt;li&gt;For example in &lt;code&gt;AddUsers&lt;/code&gt; action we have a constructor with parameter named &lt;code&gt;payload&lt;/code&gt;, this payload will basically comprise of information about the new user.&lt;/li&gt;
&lt;li&gt;This data about the newly created user will get stored inside the State whenever the action &lt;code&gt;AddUsers&lt;/code&gt; is dispatched from the component.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 7: Working with Service
&lt;/h4&gt;

&lt;p&gt;In the &lt;code&gt;designutility.service.ts&lt;/code&gt;, let’s add HTTP calls to fetch, update, add and delete to-do items. &lt;br&gt;
In this tutorial, we are using JSONPlaceholder for making fake API calls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class DesignutilityService {

  constructor(private http:HttpClient) { }

  fetchUsers(){
    return this.http.get('https://jsonplaceholder.typicode.com/users');
  }

  addUsers(userData){
    return this.http.post('https://jsonplaceholder.typicode.com/users',userData);
  }

  deleteUser(id:number){
    return this.http.delete('https://jsonplaceholder.typicode.com/users/'+id);
  }

  updateUser(payload,id:number){
    return this.http.put('https://jsonplaceholder.typicode.com/users/'+id, payload);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 8: Creating State
&lt;/h4&gt;

&lt;p&gt;Now we've arrived at the most important part of this tutorial.&lt;/p&gt;

&lt;p&gt;Create a new folder named 'states' inside src&amp;gt;app.&lt;br&gt;
Inside the states folder, create a new file named &lt;code&gt;app.state.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Injectable } from "@angular/core";
import { Action, Selector, State, StateContext } from "@ngxs/store";
import { DesignutilityService } from "../designutility.service";
import { tap } from 'rxjs/operators';
import { AddUsers, DeleteUsers, GetUsers, UpdateUsers } from "../actions/app.action";

export class UserStateModel {
    users: any
}

@State&amp;lt;UserStateModel&amp;gt;({
    name: 'appstate',
    defaults: {
        users: []
    }
})

@Injectable()
export class AppState {
    constructor(private _du: DesignutilityService) { }

    @Selector()
    static selectStateData(state:UserStateModel){
        return state.users;
    }

    @Action(GetUsers)
    getDataFromState(ctx: StateContext&amp;lt;UserStateModel&amp;gt;) {
        return this._du.fetchUsers().pipe(tap(returnData =&amp;gt; {
            const state = ctx.getState();

            ctx.setState({
                ...state,
                users: returnData //here the data coming from the API will get assigned to the users variable inside the appstate
            })
        }))
    }

    @Action(AddUsers)
    addDataToState(ctx: StateContext&amp;lt;UserStateModel&amp;gt;, { payload }: AddUsers) {
        return this._du.addUsers(payload).pipe(tap(returnData =&amp;gt; {
            const state=ctx.getState();
            ctx.patchState({
                users:[...state.users,returnData]
            })
        }))
    }

    @Action(UpdateUsers)
    updateDataOfState(ctx: StateContext&amp;lt;UserStateModel&amp;gt;, { payload, id, i }: UpdateUsers) {
        return this._du.updateUser(payload, i).pipe(tap(returnData =&amp;gt; {
            const state=ctx.getState();

            const userList = [...state.users];
            userList[i]=payload;

            ctx.setState({
                ...state,
                users: userList,
            });
        }))
    }

    @Action(DeleteUsers)
    deleteDataFromState(ctx: StateContext&amp;lt;UserStateModel&amp;gt;, { id }: DeleteUsers) {
        return this._du.deleteUser(id).pipe(tap(returnData =&amp;gt; {
            const state=ctx.getState();
            console.log("The is is",id)
            //Here we will create a new Array called filteredArray which won't contain the given id and set it equal to state.todo
            const filteredArray=state.users.filter(contents=&amp;gt;contents.id!==id);

            ctx.setState({
                ...state,
                users:filteredArray
            })
        }))
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  About Selector()
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;Selector()&lt;/code&gt; is used to get a specific piece of data from the &lt;code&gt;AppState&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In our case we are grabbing the &lt;code&gt;users&lt;/code&gt; array which is present inside the &lt;code&gt;AppState&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The selector is used to return the data back to the component with the help of &lt;code&gt;Select()&lt;/code&gt; as shown in Step 10.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 9: Documenting the State in app.module.ts
&lt;/h4&gt;

&lt;p&gt;Now that we are done with the creation of &lt;code&gt;AppState&lt;/code&gt;, it is necessary to document this state in our &lt;code&gt;app.module.ts&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;So go to imports array inside &lt;code&gt;app.module.ts&lt;/code&gt; and make the necessary change.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NgxsModule.forRoot([AppState]), NgxsLoggerPluginModule.forRoot(), NgxsReduxDevtoolsPluginModule.forRoot()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 10: Working with Component
&lt;/h4&gt;

&lt;p&gt;Component is the place from where we're gonna control the contents of the state, in our case it's &lt;code&gt;general.component.ts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We are performing basic CRUD operations on our &lt;code&gt;AppState&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For that, we have a table to display existing users, update user information, remove user and a form to insert a new user into the &lt;code&gt;AppState&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder } from '@angular/forms';
import { Select, Store } from '@ngxs/store';
import { Observable } from 'rxjs';
import { AddUsers, DeleteUsers, GetUsers, UpdateUsers } from '../actions/app.action';
import { AppState } from '../states/app.state';

@Component({
  selector: 'app-general',
  templateUrl: './general.component.html',
  styleUrls: ['./general.component.css']
})
export class GeneralComponent implements OnInit {

  //Here I have used Reactive Form, you can also use Template Driven Form instead
  userForm: FormGroup;
  userInfo: [];
  @Select(AppState.selectStateData) userInfo$: Observable&amp;lt;any&amp;gt;;

  constructor(private store: Store, private fb: FormBuilder) { }

  ngOnInit(): void {
    this.userForm = this.fb.group({
      id: [''],
      name: [''],
      username: [''],
      email: [''],
      phone: [''],
      website: ['']
    })

    this.store.dispatch(new GetUsers());

    this.userInfo$.subscribe((returnData) =&amp;gt; {
      this.userInfo = returnData;
    })
  }

  addUser() {
    this.store.dispatch(new AddUsers(this.userForm.value));
    this.userForm.reset();
  }

  updateUser(id, i) {

    const newData = {
      id: id,
      name: "Siddhesh Thipse",
      username: "iamsid2399",
      email: 'siddheshthipse09@gmail.com',
      phone: '02138-280044',
      website: 'samplewebsite.com'
    }

    this.store.dispatch(new UpdateUsers(newData, id, i));
  }

  deleteUser(i) {
    this.store.dispatch(new DeleteUsers(i));
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Few Important Points
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Import &lt;code&gt;select&lt;/code&gt; and &lt;code&gt;store&lt;/code&gt; from &lt;code&gt;ngxs/store&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Select()&lt;/code&gt; is basically used to grab the data present in the &lt;code&gt;AppState&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Notice how we are dispatching various actions to perform the desired operations, for example if we want to delete a user, we are dispatching an action named &lt;code&gt;DeleteUsers&lt;/code&gt; and passing &lt;code&gt;i&lt;/code&gt; (userid) as a parameter.&lt;/li&gt;
&lt;li&gt;So that the user having userid equal to &lt;code&gt;i&lt;/code&gt; will get deleted from the &lt;code&gt;AppState&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For designing part I have used Bootstrap 5, but you can totally skip using it if UI isn't your concern as of now.&lt;/p&gt;

&lt;p&gt;After creating the basic UI, this is how our &lt;code&gt;general.component.html&lt;/code&gt; will look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container-fluid"&amp;gt;
  &amp;lt;h2 style="text-decoration: underline;"&amp;gt;Getting started with NGXS&amp;lt;/h2&amp;gt;
  &amp;lt;div class="row my-4"&amp;gt;
    &amp;lt;div class="col-md-3"&amp;gt;
      &amp;lt;h5 style="color: grey;"&amp;gt;Add new user to State&amp;lt;/h5&amp;gt;
      &amp;lt;form [formGroup]="userForm" (ngSubmit)="addUser()"&amp;gt;
        &amp;lt;label class="form-label"&amp;gt;ID&amp;lt;/label&amp;gt;
        &amp;lt;input type="text" class="form-control mb-2" placeholder="User ID" formControlName="id"&amp;gt;
        &amp;lt;label class="form-label"&amp;gt;Name&amp;lt;/label&amp;gt;
        &amp;lt;input type="text" class="form-control mb-2" placeholder="Enter Name" formControlName="name"&amp;gt;
        &amp;lt;label class="form-label"&amp;gt;Username&amp;lt;/label&amp;gt;
        &amp;lt;input type="text" class="form-control mb-2" placeholder="Enter a unique username" formControlName="username"&amp;gt;
        &amp;lt;label class="form-label"&amp;gt;Email&amp;lt;/label&amp;gt;
        &amp;lt;input type="email" class="form-control mb-2" placeholder="example@abcd.com" formControlName="email"&amp;gt;
        &amp;lt;label class="form-label"&amp;gt;Phone&amp;lt;/label&amp;gt;
        &amp;lt;input type="number" class="form-control mb-2" placeholder="Enter Contact No." formControlName="phone"&amp;gt;
        &amp;lt;label class="form-label"&amp;gt;Website&amp;lt;/label&amp;gt;
        &amp;lt;input type="email" class="form-control mb-2" placeholder="Enter website name" formControlName="website"&amp;gt;
        &amp;lt;button type="submit" class="btn btn-primary btn-sm mt-2"&amp;gt;Add User&amp;lt;/button&amp;gt;
      &amp;lt;/form&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="col-md-9"&amp;gt;
      &amp;lt;h5 style="color: grey;"&amp;gt;User Information&amp;lt;/h5&amp;gt;
      &amp;lt;table class="table"&amp;gt;
        &amp;lt;thead&amp;gt;
          &amp;lt;tr&amp;gt;
            &amp;lt;th scope="col"&amp;gt;ID&amp;lt;/th&amp;gt;
            &amp;lt;th scope="col"&amp;gt;Name&amp;lt;/th&amp;gt;
            &amp;lt;th scope="col"&amp;gt;Username&amp;lt;/th&amp;gt;
            &amp;lt;th scope="col"&amp;gt;Email&amp;lt;/th&amp;gt;
            &amp;lt;th scope="col"&amp;gt;Phone&amp;lt;/th&amp;gt;
            &amp;lt;th scope="col"&amp;gt;Website&amp;lt;/th&amp;gt;
            &amp;lt;th scope="col"&amp;gt;Update&amp;lt;/th&amp;gt;
            &amp;lt;th scope="col"&amp;gt;Delete&amp;lt;/th&amp;gt;
          &amp;lt;/tr&amp;gt;
        &amp;lt;/thead&amp;gt;
        &amp;lt;tbody&amp;gt;
          &amp;lt;tr *ngFor="let contents of userInfo; index as i"&amp;gt;
            &amp;lt;th scope="row"&amp;gt;{{contents.id}}&amp;lt;/th&amp;gt;
            &amp;lt;td&amp;gt;{{contents.name}}&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{contents.username}}&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{contents.email}}&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{contents.phone}}&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;{{contents.website}}&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;button class="btn btn-outline-warning btn-sm" (click)="updateUser(contents.id,i)"&amp;gt;&amp;lt;i
                  class="bi bi-pencil-fill"&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;button class="btn btn-danger btn-sm" (click)="deleteUser(contents.id)"&amp;gt;&amp;lt;i
                  class="bi bi-trash-fill"&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
          &amp;lt;/tr&amp;gt;
        &amp;lt;/tbody&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgmol3081o9g5cryy6hm1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgmol3081o9g5cryy6hm1.png" alt="Landing Page UI" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it, we have successfully implemented State Management in our Angular Application.&lt;/p&gt;

&lt;p&gt;Now there is definitely more to NGXS than this, but once you've completely understood the basics, learning the advanced stuff is a cakewalk.&lt;/p&gt;

&lt;p&gt;Incase of any suggestions/queries please feel free to comment down below.&lt;/p&gt;

&lt;p&gt;Source code available on &lt;a href="https://github.com/siddheshthipse/learning-ngxs" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>beginners</category>
      <category>redux</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
