import { Dispatch } from 'redux' ; import { createStandardAction } from 'typesafe-actions' ; import { OnEvent , SignalValue } from 'vega-typings/types' ; import { State } from '../store' ; import { invalidateVega } from './vegaActions' ; import { debounce } from 'vega' ; param { string } signal param { * } value returns { Object } export const initSignal = createStandardAction ( 'INIT_SIGNAL' ) < SignalValue , string > ( ) ; param { string } signal param { * } value returns { Object } export const baseSetSignal = createStandardAction ( 'SET_SIGNAL' ) < SignalValue , string > ( ) ; const dispatchInvalidateVega = debounce ( 500 , ( dispatch ) => { dispatch ( invalidateVega ( true ) ) ; } ) ; export function setSignal ( value , signal ) { return function ( dispatch , getState ) { if ( signal . startsWith ( 'lyra_group' ) && ( signal . endsWith ( 'width' ) || signal . endsWith ( 'height' ) || signal . endsWith ( 'x' ) || signal . endsWith ( 'y' ) ) ) { const store = getState ( ) ; const isParsing = store . getIn ( [ 'vega' , 'isParsing' ] ) ; if ( ! isParsing ) { dispatchInvalidateVega ( dispatch ) ; } } dispatch ( baseSetSignal ( value , signal ) ) ; } ; } param { string } signal param { Object [ ] } streams returns { Object } export const setSignalStreams = createStandardAction ( 'SET_SIGNAL_STREAMS' ) < OnEvent [ ] , string > ( ) ; param { string } signal returns { Object } export const unsetSignal = createStandardAction ( 'UNSET_SIGNAL' ) < null , string > ( ) ;