import actionCreator from '@theatre/studio/utils/redux/actionCreator' ; import type { $FixMe , GenericAction , ReduxReducer , } from '@theatre/shared/utils/types' ; export const batchedAction = actionCreator ( '@@batched' , ( actions ) : GenericAction [ ] => actions ) ; const withBatchedActions = < S extends { } > ( reducer ) : ReduxReducer < S > => { return ( prevState , action ) : S => { if ( batchedAction . is ( action ) ) { return ( action . payload as $FixMe ) . reduce ( ( stateSoFar , a ) : S => reducer ( stateSoFar , a ) , prevState ) ; } else { return reducer ( prevState , action ) ; } } ; } ; export default withBatchedActions ;