You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Triggers: attaching actions to a state which is the current #112
When attaching actions to triggers for a state which is current, the actions won't be used as expected until the next cycling of the action state.
For example, say the current state is TriggerState.ACTIVE, and someone invokes Trigger.whenActive with some action, this action won't be started.
The root for this is that the updates to attached actions are only done in GenericTrigger.update (called by the scheduler), which only updates the actions if the state has changed.
Problem is, we can't simply act on the actions via the attach methods (like Trigger.whenActive) because it is only allowed (and possible) via GenericTrigger.update. So either we change this, or create some list which registers newly attached actions, and in update perform special handling for them.
For now, if encountered and this is a problem, cycle the trigger state. For a manual trigger, this simply involves calling activate and then deactivate (or the other way around, depending on the wanted state).
For a condition-based trigger, this is more problematic, as it requires cycling the condition. On option for this, is to cycle the source of the condition, or modify the condition with some variable to allow manually cycling it.
However, the actual cycling can only occur (and be detected) if the scheduler has noticed the change. So this is actually a bit difficult.
Activity
tomtzook commentedon Feb 23, 2024
For now, if encountered and this is a problem, cycle the trigger state. For a manual trigger, this simply involves calling
activateand thendeactivate(or the other way around, depending on the wanted state).For a condition-based trigger, this is more problematic, as it requires cycling the condition. On option for this, is to cycle the source of the condition, or modify the condition with some variable to allow manually cycling it.
However, the actual cycling can only occur (and be detected) if the scheduler has noticed the change. So this is actually a bit difficult.