import { Dispatch } from 'redux' ; import { ActionType } from '../Types' ; let handled = false ; export const updateMessage = ( message ) => ( { type : ActionType . UpdateMessage as ActionType . UpdateMessage , payload : { message } } ) ; export const handleUpdateMessage = ( ) => ( dispatch ) => { if ( handled ) { return ; } handled = true ; window . myAPI . onUpdateMessage ( ( message ) => dispatch ( updateMessage ( message ) ) ) ; } ;