The usual general principle is definitely that Python and JS values should remain in sync at all times. However, there are always specialized situations that call for different techniques. If you want to set a JS property value without syncing to the python side or triggering any python events, you can use "setv" and pass the silent flag:
@model.setv({width: width}, {silent: true})
That *may* solve your problem of property updates erroring out after a server disconnect (but I have not tried it). In terms discussing a supported mode or mechanism for apps to continue after ra sever disconnect, that's an interesting idea but it would certainly entail new development, so a GitHub issue would be the next step.
A bokeh server running a most simple app consisting of a single toggle button.
The label of the toggle button is updated on_click through binding either to a CustomJS callback or to a python function callback.
I expected the Toggle label to update when bound to the CustomJS callback after shutting down the server.
That is not the case. Seemingly because the callback is trying to sync the label on the python side.
Here is then a question on the principles (which may seem to go against the overall philosophy of bokeh):
in various circumstances the syncing with python side when using a bokeh widget is irrelevant as in this example
(here, the label is irrelevant, simply the state of the Toggle will be exploited later on)
How can this be implemented ? Is a custom extension of Toggle the way to go ?
(my secret goal is to speed up some interactions and remove some code on the python side when unnecessary)
Code:
toggle = Toggle(label='off', active=False)
code="""if (cb_obj.label === "off") {cb_obj.label ="on";} else {cb_obj.label ="off";}"""
toggle.js_on_click(CustomJS(code=code))
## for python callback:
# def set(x): toggle.label='on' if x else 'off'
# toggle.on_click(lambda x: set(x))
That looks like it could serve the purpose but can this be passed in python or js ? not sure how (looks like a statement in a coffeescript custom extension, sorry for my ignorance).
That leads me to this silent mode in general: e.g. user change a datatable entry, which results through callback in a software adjustment of other datatable fields. Would be useful that the adjustments themselves do not result in further callbacks.