import { Injectable } from '@angular/core' ; import { NgForm } from '@angular/forms' ; import { NgRedux } from '@angular-redux/store' ; import { Action , Unsubscribe } from 'redux' ; export interface AbstractStore < RootState > { dispatch ( action ) : void ; getState ( ) : RootState ; subscribe ( fn ) : Unsubscribe ; } export const FORM_CHANGED = '@@angular-redux/form/FORM_CHANGED' ; @ Injectable ( ) export class FormStore { constructor ( private store ) { } getState ( ) { return this . store . getState ( ) ; } subscribe ( fn ) { return this . store . subscribe ( ( ) => fn ( this . getState ( ) ) ) ; } valueChanged < T > ( path , form , value ) { this . store . dispatch ( { type : FORM_CHANGED , payload : { path , form , valid : form . valid === true , value } } ) ; } }