Action

interface Action<T>(source)

An operation performed when its owning Reaction executes.

Actions are imperative: execute reads the model state it needs, such as neighborhoods or concentrations, when it runs. Actions should not subscribe to observables (e.g., through Observable.onChange) to keep a copy of that state: nothing releases such subscriptions when the reaction or its node is removed, so they outlive the action and may run against nodes that are no longer in the environment; moreover, the copy goes stale whenever the state it derives from changes without the observed value changing. Reactive dependencies belong to Conditions, whose validity is owned by their reaction.

Type Parameters

T

concentration type

Properties

Link copied to clipboard
abstract val reaction: Reaction<T>

The reaction owning this action. Its Reaction.host is the model entity hosting the action, which may differ from the node it targets, if any.

Functions

Link copied to clipboard
abstract fun cloneAction(newReaction: Reaction<T>): Action<T>

Creates an equivalent action owned by newReaction, such as a reaction cloned onto a new node. An action targeting the host of its reaction targets the host of newReaction, which must then be a Node; an action targeting any other node keeps its target.

Link copied to clipboard
abstract fun execute()

Applies this action to the model.