Skip to content

TriggerExecutor

Runs a TriggerConfiguration: decides when its task should start or stop.

Each trigger type has its own executor, created by a TriggerFactory via the ExecutorFactory. A TaskControlExecutor listens to triggerEvents and controls its task on each event. Subclasses call onTrigger to fire; pausing or disposing cancels timer.

To add a new trigger type, extend this class and register a TriggerFactory that creates it.

Inheritance
Implementers

Constructors

TriggerExecutor

TriggerExecutor<TConfig extends TriggerConfiguration>()

Properties

measurements

Stream<Measurement> get measurements
override

The stream of Measurement collected by this executor.

timer

Timer? timer
getter/setter pair

A timer for subclasses to use. Cancelled on pause and dispose.

triggerEvents

Stream<TriggerEvent> get triggerEvents

The stream of events triggered from this trigger executor.

Methods

onDispose

Future<void> onDispose()
override

Callback when this executor is disposed.

Subclasses should override this, to implement any cleanup to be done before disposing.

onInitialize

bool onInitialize()
override

Called by initialize. Returns true if successfully initialized.

If false, the executor stays in ExecutorState.Created. This is a synchronous method and must be light-weight.

onPause

Future<bool> onPause()
override

Called by pause. Returns true if successfully paused.

If false, the state is not changed.

onResume

Future<bool> onResume()
override

Called by resume. Returns true if successfully resumed.

If false, the executor moves to ExecutorState.PausedButShouldBeResumed.

onTrigger

void onTrigger()

Fires this trigger by adding a TriggerEvent to triggerEvents.