import { Component, ViewEncapsulation } from '@angular/core'; import { animate, style, transition, trigger } from '@angular/animations'; import { Observable } from 'rxjs/Observable'; import { Action, Store } from '@ngrx/store'; import 'rxjs/add/operator/last'; import { DoNotUpdateAppAction, UpdateAppAction } from './store/actions/app-update.action'; import { AppState, getShowAppUpdateAvailable, deviceConfigurationLoaded, runningInElectron, saveToKeyboardState } from './store'; import { ProgressButtonState } from './store/reducers/progress-button-state'; @Component({ selector: 'main-app', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], encapsulation: ViewEncapsulation.None, animations: [ trigger( 'showSaveToKeyboardButton', [ transition(':enter', [ style({transform: 'translateY(100%)'}), animate('400ms ease-in-out', style({transform: 'translateY(0)'})) ]), transition(':leave', [ style({transform: 'translateY(0)'}), animate('400ms ease-in-out', style({transform: 'translateY(100%)'})) ]) ]) ] }) export class MainAppComponent { showUpdateAvailable$: Observable; deviceConfigurationLoaded$: Observable; runningInElectron$: Observable; saveToKeyboardState$: Observable; constructor(private store: Store) { this.showUpdateAvailable$ = store.select(getShowAppUpdateAvailable); this.deviceConfigurationLoaded$ = store.select(deviceConfigurationLoaded); this.runningInElectron$ = store.select(runningInElectron); this.saveToKeyboardState$ = store.select(saveToKeyboardState); } updateApp() { this.store.dispatch(new UpdateAppAction()); } doNotUpdateApp() { this.store.dispatch(new DoNotUpdateAppAction()); } clickedOnProgressButton(action: Action) { return this.store.dispatch(action); } }