Angular 6 NgRx Store example – Angular State Management
angular6
11
ngrx store
1
state management
1
Male avatar

loveprogramming viết ngày 20/04/2021

https://ozenero.com/angular-6-ngrx-store-example-angular-state-management

Angular 6 NgRx Store example – Angular State Management

NgRx Store is a state management solution for Angular apps that helps us build applications by working around our app's data (state). In this tutorial, we're gonna look at how to work with NgRx Store, custom Actions, Reducers. Then we will practice to understand all of them in a simple practical Angular 6 example.

Related Posts:

NgRx Store to manage App State

Why we need a State container

State container helps JavaScript applications to manage state.
=> Whenever we wanna read the state, look into only one single place – NgRx Store.
=> Managing the state could be simplified by dealing with simple objects and pure functions.

NgRx Store

Store holds the current state so that we can see it as a single source of truth for our data.

  • access state using store.select(property) (property is defined at app.module.ts in StoreModule.forRoot()).
  • update state via store.dispatch(action).
    
    export interface AppState {
    readonly customer: Customer[];
    }

// component
import { Store } from '@ngrx/store';
import { AppState } from '../../app.state';

export class MyComponent {

customers: Observable;

constructor(private store: Store) {
this.customers = store.select('customer');
}

saveCustomer(data) {
this.store.dispatch(new ActionCreateCustomer({data}));
}
}

Action

More at:

https://ozenero.com/angular-6-ngrx-store-example-angular-state-management

Angular 6 NgRx Store example – Angular State Management

Bình luận


White
{{ comment.user.name }}
Bỏ hay Hay
{{comment.like_count}}
Male avatar
{{ comment_error }}
Hủy
   

Hiển thị thử

Chỉnh sửa

Male avatar

loveprogramming

545 bài viết.
97 người follow
Kipalog
{{userFollowed ? 'Following' : 'Follow'}}
Cùng một tác giả
Male avatar
1 0
Tutorial Link: (Link) (Ảnh) Django is a Pythonbased free and opensource web framework that follows the modeltemplateview architectural pattern. A...
loveprogramming viết 11 tháng trước
1 0
Male avatar
1 0
https://loizenai.com/angular11nodejspostgresqlcrudexample/ Angular 11 Node.js PostgreSQL Crud Example (Ảnh) Tutorial: “Angular 11 Node.js Postg...
loveprogramming viết 10 tháng trước
1 0
Male avatar
1 0
Angular Spring Boot jwt Authentication Example Github https://loizenai.com/angularspringbootjwt/ (Ảnh) Tutorial: ” Angular Spring Boot jwt Authe...
loveprogramming viết 10 tháng trước
1 0
{{like_count}}

kipalog

{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}


Male avatar
{{userFollowed ? 'Following' : 'Follow'}}
545 bài viết.
97 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!