@@ -26,36 +26,39 @@ export const runStatemachineReact = async (noControls: boolean) => {
2626
2727 const root = ReactDOM . createRoot ( document . getElementById ( 'react-root' ) ! ) ;
2828 const App = ( ) => {
29- const [ testState , setTestState ] = useState < string > ( '' ) ;
30- const [ testStateButton , setTestStateButton ] = useState < string > ( text ) ;
29+ const [ debugTextState , setDebugTextState ] = useState < string > ( '' ) ;
30+ const [ codeState , setCodeState ] = useState < string > ( text ) ;
31+ const [ disposeLcState , setDisposeLcState ] = useState < boolean > ( false ) ;
3132
3233 const onTextChanged = ( textChanges : TextContents ) => {
33- setTestState ( textChanges . modified as string ) ;
34+ setDebugTextState ( textChanges . modified as string ) ;
3435 } ;
3536
3637 const appConfig = createLangiumGlobalConfig ( {
3738 languageServerId : 'react' ,
3839 codeContent : {
39- text,
40+ text : codeState ,
4041 uri : '/workspace/example.statemachine'
4142 } ,
4243 worker,
4344 messageTransports : { reader, writer }
4445 } ) ;
46+ appConfig . languageClientConfig . enforceDispose = disposeLcState ;
4547
4648 return (
4749 < >
4850 < div >
49- < button style = { { background : 'purple' } } onClick = { ( ) => setTestStateButton ( testStateButton + '\n// comment' ) } > Change Text</ button >
51+ < button style = { { background : 'purple' } } onClick = { ( ) => setCodeState ( codeState + '\n// comment' ) } > Change Text</ button >
52+ < button style = { { background : 'red' } } onClick = { ( ) => setDisposeLcState ( ! disposeLcState ) } > Swatch LC Dispose</ button >
53+
5054 < MonacoEditorReactComp
5155 style = { { 'height' : '50vh' } }
5256 vscodeApiConfig = { appConfig . vscodeApiConfig }
5357 editorAppConfig = { appConfig . editorAppConfig }
5458 languageClientConfig = { appConfig . languageClientConfig }
5559 onTextChanged = { onTextChanged }
56- modifiedTextValue = { testStateButton }
5760 />
58- < b > Debug:</ b > < br /> { testState }
61+ < b > Debug:</ b > < br /> { debugTextState }
5962 </ div >
6063 </ >
6164 ) ;
0 commit comments