Is it possible to have a widget callback function call a sub-function?
I have a number of callback functions that share some common code and I’d like to move that common code into a function to avoid code duplication.
I see the color_sliders example: http://bokeh.pydata.org/en/latest/docs/gallery/color_sliders.html
defines sub-functions within the definition of the callback but this doesn’t help my situation.
Here is a contrived example of what I’m trying to accomplish:
sub_function = CustomJS( args=dict(source=source), code = “”"
callback_select = CustomJS( args=dict(source=source), code="""
var data = source.data;
var v = cb_obj.value;
data[‘y’] = data[v];
sub_function( source )
When callback_select is run, I get the error “sub_function is not defined”.