-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add new Event parameter type #438
Conversation
Thanks. Can you add a more complete example using |
@jbednar The value should now always be False outside of the triggered function. |
As far as I can see, this is a reasonable set of behavior now: Thanks for updating it and addressing those quirks! So let's see if we can keep this behavior as a reference and consider the implementation, the API, and the naming. Taking a step back, the user story here is nominally about a Trigger parameter, but actually the Trigger Parameter itself is a no-op as currently implemented. Every Parameter can already have Would the |
To clarify my understanding of what you are suggesting, the
Instead of That might be possible by overriding the |
I'll see once there's an implementation. In any case, ideally we'd have something other than the name Trigger to govern that special behavior if it's still needed. |
I sort of have it working: It now relies on the change in value to run the callback (apparently most things don't even use trigger). Unfortunately |
At this point in the history, the implementation is simple as I've removed the changes from the trigger method. One thing that isn't clear to me, should |
I've tested the current commits, and it doesn't seem like it's working reasonably, because the callback keeps getting fired for things that have nothing to do with I'd only have expected it to be triggered for the single call to
I don't think a should become True when merely triggering If I remove the changes to Without those changes, it's now fully self contained, fully local in its implementation and effects, and easy to describe: a Trigger parameter is one that can be set, but where setting is always transient, used only to trigger other actions, with the value immediately returning to the baseline by the end of the setting operation. So I'm happy with it at the param level, if you go ahead and remove the |
Ok, I am happy to remove the latest changes to the trigger method again as the behavior on explicit triggering wasn't obvious to me (and not introducing special handling might well be the most sensible option). As soon as there is some panel code that can display Trigger parameters as buttons, I'll be able to test to see if this properly supersedes the HoloViews PR. |
@jbednar Note, I spotted the bug in the code I just reverted: I simply forgot to filter the trigger parameters against |
I think that should work because otherwise someone could trigger it and get |
Ok, both versions can work! With the latest commit, unrelated triggers (e.g I think I prefer this than leaving the value False. As either version works, I am happy to pick either as long as we have a consensus on the correct behavior. Then I'll write up some unit tests. |
I see arguments above saying that it could be confusing to invoke |
In general I would agree, but for a parameter named |
Right; I was thinking about that too. Maybe it needs a better name? param.Transient? param.Pulse? In electronics it's called a momentary switch, but I don't think that's useful here. It's hard to think of something that will make sense at the app level and at the Param level, and I haven't come up with anything better than Trigger. |
|
That's a contender. Right, events typically have a payload and this doesn't, but it's true it's an event... |
I prefer |
I've also been considering |
I don't think it is a problem to have an |
Co-authored-by: Philipp Rudiger <[email protected]>
9ce960c
to
45d72d7
Compare
There's a few things I'm struggling with the discussion here.
This seems totally bizarre to me, to me the point of the
Totally disagree here, I think that is really weird behavior because it breaks the concept of this parameter signaling whether there is an event or not, but we've had sufficient back and forth here to establish our disagreement here 😄
This is the part I'm still working through so let's go through a chain of events. The main problem I see here is to do with batching of these events, which is a problem whether or not we implement the That just leaves the resetting behavior in the batched which I'd have to work through with detailed examples but that doesn't at all depend on implementing the |
I agree. The semantics of the parameter just look like they need a more complicated implementation than we may like in order to make sense. |
I think it's probably most efficient if @philippjfr and @jlstevens together agree on an implementation that you like. I can give feedback at that point, but it won't be binding, just an opinion. So please work it out so you're happy, and we can go from there! |
@philippjfr Tests are green and I've addressed your suggestions. Ready to merge and cut a new release? |
Looks good. |
Very WIP PR to illustrate an idea we have been discussing. The API will probably change but here is the current behavior:
The idea is to add a new
Trigger
parameter type which would replace many uses ofAction
. What you want to know about aTrigger
parameter is whether it has been triggered (e.g a button clicked). The value is True if the parameter has just been triggered, otherwise False (which means a trigger call has happened since not involving that parameter).One possibility which is more complicated is to avoid
b.param.trigger('a')
by settingb.a = True
(setting to True triggers, whether or not the value is True already). This involves working inside__set__
which can get quite tricky.At this point, this PR aims to be a place to discuss this suggestion more than something to merge. The idea is that this parameter would mean holoviz/holoviews#4611 is not necessary (though panel would need to be updated to display this parameter type as appropriate buttons).
TODO
Bar
at the moment in the example above)__set__