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

Better handling of rapid action events firing #111

Open
adamghill opened this issue Jan 6, 2021 · 3 comments
Open

Better handling of rapid action events firing #111

adamghill opened this issue Jan 6, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@adamghill
Copy link
Owner

Related to #100 for models, but will need a separate approach because actions always need to go through the entire AJAX lifecycle since anything can happen inside the component's view.

One thought is to experiment with throttling actions and combining them into one actionQueue in the AJAX call if they happen in quick enough succession. Would potentially reduce the number of calls that would need to be made.

Another more long-term issue will be created to do a performance optimization (#110).

@adamghill
Copy link
Owner Author

Just a note that really fast actions do get combined into one actionQueue. But, maybe it can be tweaked to work better with some testing.

@frbor
Copy link

frbor commented Jan 19, 2021

I'm having some issues which I'm not sure will be covered by this issue or if is a separate issues. I'm testing a combination of polling + manually modifying the state and have created, and have update the polling example in this branch:

<div unicorn:poll-1000="get_date">
    current_time: {{ current_time|date:"s" }}

    <button u:click="slow_update()">Increase counter: {{counter}}</button>
</div>
class PollingView(UnicornView):
    polling_disabled = False
    counter = 0
    current_time = now()

    def slow_update(self):
        self.counter += 1
        time.sleep(0.8)  # Simulate slow request

    def get_date(self):
        self.current_time = now()

I see that if I have slow requests (forced with a sleep in this example) and the polling is started just after the button click, the counter is not increased, as I guess the counter is overwritten my the state from the polling.

However, I'm not sure if the polling is an "action" so it fits here?

@adamghill
Copy link
Owner Author

I created a new issue for now because even though they feel related I'm not sure if the solution will be the same.

@adamghill adamghill added the bug Something isn't working label Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants