How can I have finer control over observe() observables?

Currently, there are two ways to react to something to perform side effects: observe() and observeEvent(). observe automatically observes anything that is in its expression, and you need to explicitly silence stuff that you don't want to react to. observeEvent() evaluates an expression, which is reactive on all reactives that are written in, and the body is executed only if the result of the expression changes.

The problem I have is that I am using a lot of reactive variables in the body, but I only want to observe and react to three. my first instinct was to have

}, { mycode })

but this does not trigger if either var1 or var 2 or var3 change. The result of the expression is var3(), and mycode is executed only if var3() changes, not if var1 or var2 do. I thought about combining them (e.g. with an and expression), but it's not always trivial and it depends on the variables.

Is there a preferred way or pattern to respond only on specific variables?

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.