JohnCoene / javascript-for-r

📚 JavaScript for R CRC Book
https://javascript-for-r.com/
Other
185 stars 47 forks source link

17.3.3 Handle Data - Unclear where `if (HTMLWidgets.shinyMode){...}` should go #45

Open Shaunson26 opened 1 year ago

Shaunson26 commented 1 year ago

https://book.javascript-for-r.com/shiny-widgets.html ... 17.3.3 Handle Data .. unclear if this chunk should be 'anywhere' in the gio.js file or within the HTMLWidgets.widget() body (within in factory?) .. i put it within the factory function, and it seems to be working ..

Edit: Ok it seems that it is best outside the widget body, otherwise the predicate is called for each widget instance .. it is just when my shiny page first loads, my proxy function fails - seems like an order of operations thing.. once i move my slider, the proxy functions is working as expected

Edit 2: proxy$session$onFlushed approach solved the issue, waiting before sending the customMessage..