See the JS tab for the code and browser console for messages
Click this button to change the value of the sig_string signal to "Las Vegas"
Click this button to change the value of the sig_string signal to "New York"
Click this button to decrement the value of the sig_n with 3
Click this button to increment the value of the sig_n signal by 5
The red bordered element contains the value of the subscribeStateScript function for the following template string
"\" City: {{s.city}}; Number: {{ n.sig_n}}; Number*3: \"+{{ n.sig_n }}*3 "
{#You will need to change both sig_n and sig_string in order for the value to change from the default one.#}
<p>See the JS tab for the code and browser console for messages</p> <p> Click this button to change the value of the <b>sig_string</b> signal to "Las Vegas" <ch5-button label="Btn1" sendEventOnClick="trig1"></ch5-button> </p> <p> Click this button to change the value of the <b>sig_string</b> signal to "New York" <ch5-button label="Btn2" sendEventOnClick="trig2"></ch5-button> </p> <p> Click this button to decrement the value of the <b>sig_n</b> with 3 <ch5-button label="Btn3" sendEventOnClick="trig3"></ch5-button> </p> <p> Click this button to increment the value of the <b>sig_n</b> signal by 5 <ch5-button label="Btn4" sendEventOnClick="trig4"></ch5-button> </p> <p> The red bordered element contains the value of the subscribeStateScript function for the following template string <code>"\" City: {{s.city}}; Number: {{ n.sig_n}}; Number*3: \"+{{ n.sig_n }}*3 "</code> {#You will need to change both <b>sig_n</b> and <b>sig_string</b> in order for the value to change from the default one.#} </p> <div id="updated-element" style="border:1px solid blue"></div>
(function(CrComLib){ var el =document.querySelector('#updated-element'); const signalScript="CrComLib.textformat(\"City: {1}, Number: {2}, Number*3: {3}\",\"{{s.city}}\",{{n.sig_n}},{{n.sig_n}}*3)"; var callback = function(result){ console.log(result); el.textContent = result; } CrComLib.subscribeStateScript(signalScript, callback, 'defaultValue'); })(CrComLib);