Skip to content

Commit c4225ed

Browse files
(api-break) Falseを返す事による予約解除をやめる
1 parent 13a9435 commit c4225ed

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

src/asyncgui_ext/clock.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def tick(self, delta_time):
8181
if e._deadline > cur_time:
8282
tba_append(e)
8383
continue
84-
if e.callback(cur_time - e._last_tick) is False or e._interval is None:
84+
e.callback(cur_time - e._last_tick)
85+
if e._interval is None:
8586
continue
8687
e._deadline += e._interval
8788
e._last_tick = cur_time
@@ -118,21 +119,6 @@ def schedule_once(self, func, delay) -> ClockEvent:
118119
def schedule_interval(self, func, interval) -> ClockEvent:
119120
'''
120121
Schedules the ``func`` to be called repeatedly at a specified interval.
121-
122-
There are two ways to unschedule the event. One is the same as :meth:`schedule_once`.
123-
124-
.. code-block::
125-
126-
with clock.schedule_interval(func, 10):
127-
...
128-
129-
The other one is to return ``False`` from the callback function.
130-
131-
.. code-block::
132-
133-
def func(dt):
134-
if some_condition:
135-
return False
136122
'''
137123
cur_time = self._cur_time
138124
event = ClockEvent(cur_time + interval, cur_time, func, interval)
@@ -195,7 +181,6 @@ def callback(dt):
195181
n -= 1
196182
if not n:
197183
task._step()
198-
return False
199184

200185
event = self.schedule_interval(callback, 0)
201186

@@ -222,9 +207,9 @@ async def anim_with_dt(self, *, step=0) -> AsyncIterator[TimeUnit]:
222207
def callback(dt):
223208
print(dt)
224209
if some_condition:
225-
return False
210+
event.cancel()
226211
227-
clock.schedule_interval(callback, 10)
212+
event = clock.schedule_interval(callback, 10)
228213
229214
**Restriction**
230215
@@ -479,7 +464,6 @@ def _update(setattr, zip, min, obj, duration, transition, output_seq_type, anim_
479464
# time to stop ?
480465
if progress >= 1.:
481466
task._step()
482-
return False
483467

484468
_update = partial(_update, setattr, zip, min)
485469

0 commit comments

Comments
 (0)