import { Action , Store , } from 'redux' ; import { AbstractStore , FormStore , } from './form-store' ; export const provideReduxForms = < T > ( store ) => { const abstractStore = wrap ( store ) ; return [ { provide : FormStore , useValue : new FormStore ( < any > abstractStore ) } ] ; } ; const wrap = < T > ( store ) : AbstractStore < T > => { const dispatch = ( action ) => store . dispatch ( action ) ; const getState = ( ) => < T > store . getState ( ) ; const subscribe = ( fn ) => store . subscribe ( ( ) => fn ( store . getState ( ) ) ) ; return { dispatch , getState , subscribe } ; } ;