onAttach

abstract fun onAttach(model: Model, scope: CoroutineScope)(source)

Called once on the simulation thread before the experiment is initialized.

Register observers, open files, or start background coroutines here. This method must not block indefinitely; it runs on the same thread that will execute the simulation.

Parameters

model

the model that is about to run; configure observers on it here

scope

the coroutine scope of the run; child coroutines launched here will be cancelled automatically when the run ends