-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] pattern-matching callbacks with empty or partly-empty Output #1216
Comments
Also: #1212 treats all-missing inputs as a normal situation again. What about all-missing outputs when some or all inputs are present? That feels like it might be something we should support for similar reasons, but I haven't tested the actual behavior both today and prior to 1.11. |
Initial reaction: No. Could this be handled in a satisfactory way, and explicitly, if we were to allow callback Input to also be its output? - no infinite loops (arguably, there's nothing an infinite callback loop could do that couldn't be done in a single callback looping until it reaches some stable state?) |
Good, that's the way I'm leaning as well. Curious to hear other perspectives too!
If the goal is just to respond to changes in available elements, this is what you get from using the
haha that's an interesting thought... automatic iteration for an unknown duration. 😱 |
Agreed: Initial reaction: No
Agreed with this as well 👍 |
As reported in the dash 1.11 forum post we currently have problems when a pattern-matching callback matches no items in its
Output
(s). This particular case is straightforward, the callback simply shouldn't fire and no error should occur. But there are multiple variants that deserve scrutiny:Output({key1: ALL})
(the case posted on the forum - theALL
can match no items)Output({key1: ALL, key2: MATCH})
(same thing but the pattern has aMATCH
too - again the callback should not fire with no matching items)[Output({key1: ALL}), Output({key2: ALL})]
(twoALL
patterns - if either one matches items the callback should fire, but if neither matches anything it should not)[Output({key1: ALL}), Output(str)]
(anALL
and a simple string ID - the callback should always fire)[Output({key1: ALL, key2: MATCH}), Output({key2: MATCH})]
(anALL+MATCH
and aMATCH
- the callback should always fire)Should removing items from an
Output(ALL)
trigger the callback?This I'm not so sure about. Removing items from an
Input(ALL)
certainly should and does trigger the callback, and adding items toOutput(ALL)
triggers the callback as an "initial call" for the new item.In practice this currently mainly happens when you remove the entire category - but that will change when we implement array operation callbacks #968.
The argument I can think of for not triggering is that the inputs to the callback haven't changed, and if the callback is expensive you may not want to rerun it just because the user deleted something from the page. Also if it's clear to users that this is expected, they can force the callback to run on item removal by adding
Input({key1: ALL}, "id")
matching theOutput({key1: ALL}, prop)
The argument I see in favor of triggering is that these outputs often depend on each other, and the list of outputs you're required to return can itself be thought of as an input. Indeed, this is how I discovered the issue, as I made a test app one way to cover case (1) and then tried to modify it for case (4) and was surprised that it mostly worked, until I cleared the
ALL
match.Here's the original version of the test app (only works on the missing-outputs branch):
And the modification, combining the last two callbacks into one:
Which works great until 4 clicks of the
items
button, whencontent
gets cleared.You can fix it either by adding
items
as an input and recalculatingn1
from that, or by addingInput({"i": ALL}, "id")
. The question is whether that should be necessary or if I should treat this as a bug.The text was updated successfully, but these errors were encountered: