-
Notifications
You must be signed in to change notification settings - Fork 25
Beta #27
Conversation
|
||
################################################################### | ||
|
||
def setScheduleUpdates( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this method completely.
As we have already the different events, then we should schedule only them, when some one is subscribed on the event.
Example components:
We should schedule only self.json.schedule(components_cycle, self.refresh_components)
, when some is subscribed for the liveSpan events, otherwise we are requesting useless information. This will also decrease the number of requests. What do you think?
My idea was something like:
class EventEmitterWithSchedule(EventEmitter):
"""A event emitter, which starts a scheduler when at least one subscriber is subscribed"""
def __init__(self, json: EcoVacsJSON, seconds: int, timer_function):
super().__init__()
self._json = json
self._seconds = seconds
self._timer_function = timer_function
def subscribe(self, callback) -> EventListener:
if len(self._subscribers) == 0:
self._json.schedule(self._seconds, self._timer_function)
return super().subscribe(callback)
....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@And3rsL what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a cleaner way to do it :) i need some time to code it
After some day scheduler stop working, need to figure out why |
Any findings? Is there something I can help you with? |
Created this PR to give you feedback about it