1- import { createMemo } from "solid-js" ;
1+ import { createMemo , createSignal , on } from "solid-js" ;
22
33import {
44 BlockTitle ,
@@ -11,6 +11,7 @@ import {
1111} from "catcolab-ui-components" ;
1212import type { MassActionProblemData , MorType , ObType , QualifiedName } from "catlog-wasm" ;
1313import type { ModelAnalysisProps } from "../../analysis" ;
14+ import { ExecuteGuard } from "../../components" ;
1415import { morLabelOrDefault } from "../../model" ;
1516import { ODEResultPlot } from "../../visualization" ;
1617import { createModelODEPlotWithEquations } from "./model_ode_plot" ;
@@ -101,12 +102,28 @@ export default function MassAction(
101102 ( model ) => props . simulate ( model , props . content ) ,
102103 ) ;
103104
104- const plotResult = ( ) => result ( ) ?. plotData ;
105+ const [ autoUpdate , setAutoUpdate ] = createSignal ( true ) ;
106+ const [ shouldUpdate , trigger ] = createSignal ( false ) ;
107+ const plotResult = createMemo (
108+ on (
109+ ( ) => ( autoUpdate ( ) ? result ( ) ?. plotData : shouldUpdate ( ) ) ,
110+ ( ) => result ( ) ?. plotData ,
111+ ) ,
112+ ) ;
105113 const latexEquations = ( ) => result ( ) ?. latexEquations ?? [ ] ;
106114
115+ const execute = ( ) => (
116+ < ExecuteGuard
117+ text = "Execute"
118+ triggerText = "auto-simulate"
119+ canTrigger = { [ autoUpdate , setAutoUpdate ] }
120+ shouldTrigger = { [ shouldUpdate , trigger ] }
121+ />
122+ ) ;
123+
107124 return (
108125 < div class = "simulation" >
109- < BlockTitle title = { props . title } />
126+ < BlockTitle title = { props . title } settingsPane = { execute ( ) } />
110127 < Foldable title = "Parameters" defaultExpanded >
111128 < div class = "parameters" >
112129 < FixedTableEditor rows = { obGenerators ( ) } schema = { obSchema } />
0 commit comments