import { Modeler } from 'redux-aggregate' ; export interface SummaryST { name : string ; counterCount : number ; todosCount : number ; now : string ; bgColor : string ; } export const SummaryModel = injects => ( { name : '' , counterCount : 0 , todosCount : 0 , now : '' , bgColor : '#fff' , ... injects } ) ; function sum ( state ) { return state . counterCount + state . todosCount ; } function sumLabel ( state ) { return `counterCount + state.todosCount = ${ sum ( state ) }` ; } export const SummaryQR = { sumLabel } ; const Timer = { tick ( state , timeLabel ) { return { ... state , now : timeLabel } ; } } ; const Todos = { addTodo ( state ) { return { ... state , todosCount : state . todosCount + 1 } ; } } ; const Counter = { increment ( state ) { return { ... state , counterCount : state . counterCount + 1 } ; } , decrement ( state ) { return { ... state , counterCount : state . counterCount - 1 } ; } } ; export const SummarySB = { Timer , Todos , Counter } ;