import * as _ from 'lodash' ; export interface Action < T > { readonly type : string ; readonly payload : T ; readonly error ? : boolean ; NEXT ? : Action < any > ; } export interface ActionCreator < T > { readonly actionType : string ; ( payload ) : Action < T > ; } interface GenericActionCreator < T > { readonly actionType : string ; ( ... payload ) : Action < T > ; } export function actionCreator < T > ( actionType ) { return _ . assign ( ( payload ) : any => ( { type : actionType , payload , error : false } ) , { actionType } ) ; } interface EmptyActionCreator { readonly actionType : string ; ( ) : Action < void > ; } export function emptyActionCreator ( actionType ) { return _ . assign ( ( ) : any => ( { type : actionType , error : false } ) , { actionType } ) ; } export function errorActionCreator ( actionType ) { return _ . assign ( ( payload ) : any => ( { type : actionType , payload , error : true } ) , { actionType } ) ; } export function isActionOfType < T > ( action , creator ) { return action . type === creator . actionType ; } export function combine < T extends U , U > ( currentState , newState ) { return _ . assign ( { } , currentState , newState ) ; } export interface StoreAccessor { [ key ] : any ; } export interface ActionHandler { ( action ) : Action < any > ; }