import { Component, OnInit } from "@angular/core"; import { Store } from "@ngrx/store"; import { Observable } from "rxjs/Observable"; import { DataStorageService } from "../../shared/data-storage.service"; import * as fromApp from '../../ngrx/app.reducers'; import * as fromAuth from '../../auth/ngrx/auth.reducers'; import * as AuthActions from '../../auth/ngrx/auth.actions'; import * as RecipeActions from '../../recipes/ngrx/recipe.actions'; @Component({ selector: 'app-header', templateUrl: './header.component.html' }) export class HeaderComponent implements OnInit { authState: Observable; constructor(private dataStorageService: DataStorageService, private store: Store) {} ngOnInit() { this.authState = this.store.select('auth') } onSaveData() { this.store.dispatch(new RecipeActions.StoreRecipes()); } onFetchData() { this.store.dispatch(new RecipeActions.FetchRecipes()); } onLogout() { this.store.dispatch(new AuthActions.Logout()); } }