Skip to content

Instantly share code, notes, and snippets.

View Tecayehuatl's full-sized avatar
🌟
One task at the time...

Enrique Delgado Tecayehuatl Tecayehuatl

🌟
One task at the time...
View GitHub Profile
export interface IApp {
username: string;
password: string;
authenticationMessage: string;
}
export interface IAppState {
AppState: IApp;
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { StoreModule } from '@ngrx/store';
import { reducers, metaReducers } from './store';
@NgModule({
import { Component } from '@angular/core';
import { Store } from '@ngrx/store';
import { IAppState } from './store/app.interface';
import { login } from './store/actions/app.actions';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { StoreModule } from '@ngrx/store';
import { reducers, metaReducers } from './store';
@NgModule({
declarations: [AppComponent],
import { ActionReducerMap, MetaReducer } from '@ngrx/store';
import { IAppState } from './app.interface';
import { AppReducer } from './reducers/app.reducers';
export const reducers: ActionReducerMap<IAppState> = {
AppState: AppReducer,
};
export const metaReducers: MetaReducer<IAppState>[] = [];
import { createReducer, on, Action } from '@ngrx/store';
import { initialAppState, IApp } from '../app.interface';
import { login, loginSuccess, loginFail } from '../actions/app.actions';
export const userFeatureKey = 'AppState';
export const reducer = createReducer(
initialAppState as IApp,
on(login, (state) => ({
...state,
import { createAction, props } from '@ngrx/store';
export const login = createAction(
'[loginModule] log user Action',
props<{ usernamae: string; password: string }>()
);
export const loginSuccess = createAction(
'[loginModule] log user Success Action'
);
@Tecayehuatl
Tecayehuatl / index.ts
Last active May 25, 2020 03:20
Reducer index
import { ActionReducerMap, MetaReducer } from '@ngrx/store';
import { IAppState } from './app.interface';
export const reducers: ActionReducerMap<IAppState> = {};
export const metaReducers: MetaReducer<IAppState>[] = [];
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { StoreModule } from '@ngrx/store';
@NgModule({
declarations: [
AppComponent
@Tecayehuatl
Tecayehuatl / package.json
Last active May 25, 2020 01:23
information of ngrx/store package.json
{
"name": "ngrx-store-walkthrough",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"