Skip to content
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

When there are multiple actions in the queue, only call the "updated" methods for the last action #697

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adamghill
Copy link
Owner

@adamghill adamghill commented Jun 22, 2024

This is a prototype to solve for #696. It changes the semantics of how the updated methods work, though -- instead of getting called for every action, when there are multiple actions in a queue (for example with deferred), the updated method would only get called once for the last action.

I do wonder:

  1. If adding a new method (instead of using "updated") would be more appropriate, although I can't think of a good name for it.
  2. Could I pass another argument along with the property value which indicates it's the last value in a queue? I can't think of a nice argument name for that either. Something like this arg name feels very messy, but would be "correct": def updated_search(self, search, is_last_or_only_action.
  3. Another option would be add something to the component instance (aka self) which could be used, but this feel like it would expose a lot of internals that probably aren't all that useful to most people. But, theoretically I could add component_request to self, so then component code to do something with the last action would look something like this:
def updated_search(self, search):
    action_queue = self.component_request.action_queue

    if len(action_queue) > 1:
        last_action = action_queue[-1:][0]
            
        if last_action.payload.get("name") == "search" and last_action.payload.get("value") == search:
            print(f"this is the last one action: {search}")

That seems like a lot of boilerplate code for something that should be easier for users of the framework.

@adamghill adamghill self-assigned this Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant