You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a UI that has 3 components (dropdowns), A, B, C that can each change independently but the values of B are based on A and the values of C are based on B (all of which is defined in a table; see example below). Right now, I have 2 separate @reactive.effect-decorated functions (but without a @reactive.event restriction) that update the options in B when something changes and the options in C when something changes. My issue is that sometimes C updates before B when A changes because there's no strict rule stating otherwise. How do I solve this issue?
If I attached a @reactive.event on A to change the options in B and a @reactive.event on B to change the options in C, then a change in A that happens to have an identical B option will not trigger an update on C. For example consider the following minimal table:
A
B
C
one
0
foo
one
1
fa
two
3
bar
If A has "one" selected and I switch it to "two" I would like C to give "bar" as the only option. This is only possible if C can update either when B changes or A changes but there's no rule stating that B should update before C does.
If I have no @reactive.event restrictions then sometimes C updates before B and I get an erroneous lookup for, e.g. A == "two" and B == 0 and C =="bar"
How do I force reactive order to be A --> B --> C? Hope this makes some sense.
The text was updated successfully, but these errors were encountered:
Thank you @wch ! I just noticed. However I'm still missing something. When the A drop-down changes and triggers an update on the B drop-down items (via ui.update_select), I cannot get C's @reactive.effect to read the updated B value (via input.B()); instead I get the original B value. Any ideas?
Sorry you're right. I was just about to do that but I figured out what the problem was. C's @reactive.effect was being called multiple times, as A cascaded to B and B cascaded to C. As soon as I put an if statement for the table lookup I was doing to be valid, it worked (it essentially skipped "intermediate" look-ups that gave null entries).
I have a UI that has 3 components (dropdowns), A, B, C that can each change independently but the values of B are based on A and the values of C are based on B (all of which is defined in a table; see example below). Right now, I have 2 separate
@reactive.effect
-decorated functions (but without a@reactive.event
restriction) that update the options in B when something changes and the options in C when something changes. My issue is that sometimes C updates before B when A changes because there's no strict rule stating otherwise. How do I solve this issue?If I attached a
@reactive.event
on A to change the options in B and a@reactive.event
on B to change the options in C, then a change in A that happens to have an identical B option will not trigger an update on C. For example consider the following minimal table:If A has "one" selected and I switch it to "two" I would like C to give "bar" as the only option. This is only possible if C can update either when B changes or A changes but there's no rule stating that B should update before C does.
If I have no
@reactive.event
restrictions then sometimes C updates before B and I get an erroneous lookup for, e.g.A == "two" and B == 0 and C =="bar"
How do I force reactive order to be A --> B --> C? Hope this makes some sense.
The text was updated successfully, but these errors were encountered: