Open adamghill opened 3 years ago
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.
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?
I created a new issue for now because even though they feel related I'm not sure if the solution will be the same.
Related to https://github.com/adamghill/django-unicorn/issues/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 (https://github.com/adamghill/django-unicorn/issues/110).