refactor: runtime side effects

This commit is contained in:
Carlos Valente
2024-04-27 22:37:45 +02:00
committed by Carlos Valente
parent accdf2c396
commit 6e61a7ecf9
3 changed files with 148 additions and 143 deletions
@@ -1,7 +1,7 @@
import { LogOrigin } from 'ontime-types';
import IIntegration, { TimerLifeCycleKey } from './IIntegration.js';
import { getState } from '../../stores/runtimeState.js';
import { eventStore } from '../../stores/EventStore.js';
import { logger } from '../../classes/Logger.js';
class IntegrationService {
@@ -20,14 +20,7 @@ class IntegrationService {
}
dispatch(action: TimerLifeCycleKey) {
/**
* We currently get the state from the runtimeState store
* This solves an issue where the state is not updated until after the integrations have ran
* The workaround solves the issue with the tradeoff of
* - we do not have access to data outside runtimeState (eg: messages or auxtimers)
* - we couple the integrationService to runtimeState
*/
const state = getState();
const state = eventStore.poll();
this.integrations.forEach((integration) => {
integration.dispatch(action, state);
});