export class MyComponent {
private _subscription: Subscription;
ngOnInit() {
this._subscription = myObservable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { inject, TestBed } from '@angular/core/testing'; | |
import { of } from 'rxjs/observable/of'; | |
import { LoggingService, LocalStorageService } from '../'; | |
import { RouterEventService } from '../../routing'; | |
export class MockLocalStorageService { | |
setItem() {} | |
getItem() { return []; } | |
} | |
export class MockRouterEventService { |
A complete list of RxJS 5 operators with easy to understand explanations and runnable examples.
By: @BTroncone
Also check out my lesson @ngrx/store in 10 minutes on egghead.io!
Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!
Table of Contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//specify what state slices you would like to keep synced with local storage | |
export function main() { | |
return bootstrap(TodoApp, [ | |
provideStore(APP_REDUCERS), | |
localStorageMiddleware('todos', 'visibilityFilter') | |
]) | |
.catch(err => console.error(err)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component, Input, Output, EventEmitter} from "angular2/core"; | |
import {Todo} from "../services/Todo-Service"; | |
@Component({ | |
selector: 'todo-item', | |
styles: [ | |
` | |
.complete{ | |
text-decoration: line-through; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from 'angular2/core'; | |
import { Storage } from './storage'; | |
import { CurrentUser } from '../interfaces/common'; | |
@Injectable() | |
export class Authentication{ | |
private _storageService : Storage; | |
private _userKey : string = "CURRENT_USER"; | |
constructor(storageService : Storage){ |