import { Component , OnInit , OnDestroy } from 'angular2/core' ; import { Observable } from 'rxjs/Observable' ; import { Subject } from 'rxjs/Subject' ; import { Subscription } from 'rxjs/Subscription' ; import { Store } from '@ngrx/store' ; import { login } from '../../services/auth-actions.service' ; import { LoginFormComponent } from '../../components/login-form.component/login-form.component' ; @ Component ( { selector : 'auth-route' , directives : [ LoginFormComponent ] , template : require ( './auth.route.html' ) } ) export class AuthRoute implements OnInit , OnDestroy { public onLogin$ = new Subject < any > ( ) ; public loginAction$ = this . onLogin$ . map ( login ( ) ) ; private _subscription : Subscription ; constructor ( private _store ) { } ngOnInit ( ) { this . _subscription = Observable . merge ( this . loginAction$ ) . subscribe ( this . _store ) ; } ngOnDestroy ( ) { this . _subscription . unsubscribe ( ) ; } }