Can I reduce the reactivity of functions?

Hello,

I have some buttons that call functions with reactive variables in them. When those variables change, the buttons re-render, and are un-clickable for a moment. Some of my reactive variables are time-based, and so the buttons are constantly re-rendering, and become unreliable. Here’s an example:

The workaround I found was to use mutable variables. This works, but became a pain point in a large notebook, with variables and functions that reference other variables and functions. The whole chain of state has to be conscious of reactivity to keep the buttons reliable.

I kinda wish that I could mark a function as non-reactive, or that in certain contexts functions were non-reactive to begin with.

Is there a way to get this behavior, or a better way to approach this overall?

Thanks for your time.

Can you share your original notebook, or describe what role the buttons play in your dataflow and why they need to depend on other cells?

In your example, the structure I would recommend is:

  • a button with its own internal state / counter
  • counter without a dependency on button
  • tally as the sum of the button value and counter