'Bokeh RangeTool update on `mouse_released`

I have a bokeh layout that consist of a main_fig and a range_selector_fig. range_selector_fig has the widest window possible. I use a RangeTool on range_selector_fig to set main_fig.x_range in its simplest form as follows,

range_tool = RangeTool(x_range=main_fig.x_range)
range_tool.overlay.fill_color = "navy"
range_tool.overlay.fill_alpha = 0.2
range_selector_fig.add_tools(range_tool)

However, main_fig range update is calculation heavy. Every time range_tool.x_range is updated the calculation is triggered continuously as expected causing a laggy and unpleasing figure update. main_fig callback assignment is as follows,

main_fig.x_range.js_on_change("start", callback)

callback being an instance of Bokeh CustomJS class.

Is there a way to trigger calculations not continuously but just after the mouse button is released while selecting range using range_tool?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source