How to temporarilly disable on_change callbacks?

Hello,
consider the following: We have a map with different geographic entities (e.g. region, district, chiefdom) and one Select per such entity (e.g. on Select to select region of a country, next to select district, etc.). With this one can navigate a country’s structure from national to local level.

We now added a ‘free text’ search field using AutoCompleteInput with which you can search these entities on any level, e.g. you could select an auto complete entry that is a region and thus only sets the first select or a chiefdom which would set all 3 selects (region, district, chiefdom).

Any choice from AutoCompleteInput should be reflected in the selects as well which means that we set update the value of several selects after another which means the map (and additional dependent data displays) updates in several steps. This we don’t want.

What can we do to avoid this behavior?

  • use ‘remove_on_change’ to temporarily remove the callbacks to prevent them from being called and only trigger the ‘last’ on_change. This should work but seems quite messy.
  • maybe have a separate data structure that encodes the current ‘zoom-level’ and ‘location’? Currently this is encoded in the different selects. This object could ensure that all dependent displays are update correctly without the additional steps

Is there an idiomatic way to achieve this?

Thank you,
Johannes

EDIT: I think using ColumnDataSource might be good candidate to store the state of the dashboard.

If I understand you correctly, the best way IMO would be to use debounced/throttled callbacks. There are code examples with Python decorators that allow you to debounce any call.

Thank you. Debouncing wouldn’t work here because it would let e.g. the first change through and the subsequent once would be filtered, but the subsequent once contain relevant information.

We ended up creating a ‘map_state’ ColumnDataSource which encodes the zoom state of the map (e.g. which region, district etc. was selected). This way we can insure only a single callback is triggered even if multiple values are changed.