#Comprehensive Introduction to @ngrx/store By: @BTroncone
Written version of future egghead.io video series.
#Comprehensive Introduction to @ngrx/store By: @BTroncone
Written version of future egghead.io video series.
function person(state, action) { | |
state = state || {}; | |
switch(action.type){ | |
case 'ADD_INFO': | |
return Object.assign({}, state, action.payload); | |
default: | |
return state; | |
} | |
} |
var Hapi = require('hapi'); | |
const server = new Hapi.Server({ | |
cache: [ | |
{ | |
name: 'redisCache', | |
engine: require('catbox-redis'), | |
host: '127.0.0.1', | |
partition: 'cache' | |
} |
import { Component, Directive, TemplateRef, ViewContainerRef, Injector, | |
ComponentFactoryResolver, Renderer } from '@angular/core'; | |
@Component({ | |
selector: 'alert', | |
template: ` | |
<div class="alert alert-success" role="alert"> | |
<ng-content></ng-content> | |
</div> | |
` |
/* https://codepen.io/Craigtut/pen/dIfzv */ | |
.ripple { | |
overflow: hidden; | |
} | |
.ripple-effect { | |
position: absolute; | |
border-radius: 50%; | |
width: 50px; | |
height: 50px; |
<div class="form-group" [ngClass]="{'has-danger': feedback && !state.valid && !state.control.pristine }"> | |
<label *ngIf="label" class="form-control-label">{{label}}</label> | |
<ng-content></ng-content> | |
<div *ngIf="feedback && !state.valid && !state.pristine"> | |
<div *ngIf="state.hasError('required')" class="form-control-feedback">Required field.</div> | |
<div *ngIf="state.hasError('minlength')" class="form-control-feedback">Has to be at least {{state.getError('minlength').requiredLength}} characters long.</div> | |
<div *ngIf="state.hasError('maxlength')" class="form-control-feedback">Has to be less than {{state.getError('maxlength').requiredLength}} characters long.</div> | |
<div *ngIf="state.hasError('incorrectFileExtension')" class="form-control-feedback">File extension has to be <code>{{state.getError('incorrectFileExtension').requiredFileExtension}}</code>.</div> |
import { Injectable } from '@angular/core'; | |
import { Router } from '@angular/router'; | |
import { CanActivate, CanActivateChild, ActivatedRouteSnapshot } from '@angular/router'; | |
import { AuthS } from '../../routes/auth/auth.s'; | |
import { UserSt } from '../../routes/user/user.st'; | |
import { isEmpty } from 'lodash'; | |
@Injectable() | |
export class LoggedInG implements CanActivate/*, CanActivateChild*/ { |
// Imports | |
import { NgModule } from '@angular/core'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { SharedModule } from './shared/modules'; | |
import { AppRoutingM } from './app-routing.m'; | |
import { TranslateModule, TranslateLoader, TranslateStaticLoader } from 'ng2-translate'; | |
// Declarations | |
import { AppC } from './app.c'; | |
import { errorD } from './routes/error/index'; |
import { Injectable } from '@angular/core'; | |
import { BehaviorSubject, Subscription } from 'rxjs'; | |
import { get, set, assign, merge, isEmpty } from 'lodash'; | |
import { IS_DEV } from '../constants'; | |
import { ResMsgHandlerS } from './res-msg-handler.s'; | |
export interface IStateOpts { | |
initState?: Object; | |
} |
import { ValidatorFn, AbstractControl } from '@angular/forms'; | |
/** | |
* All file sizes specified in bytes. | |
*/ | |
export function emailValidator(): ValidatorFn { | |
return (control: AbstractControl): {[key: string]: any} => { | |
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
const passed = re.test(control.value); |