| Total Complexity | 2 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from ..protocol import Observable, Observer, Subscription, default_subscription |
||
| 2 | from .rx_create import rx_create |
||
| 3 | |||
| 4 | __all__ = ["rx_range"] |
||
| 5 | |||
| 6 | |||
| 7 | def rx_range(start: int, stop: int, step: int = 1) -> Observable: |
||
| 8 | """Create an observable sequence of range. |
||
| 9 | |||
| 10 | Args: |
||
| 11 | start (int): initiale value |
||
| 12 | stop (int): last value |
||
| 13 | step (int): default increment (default: {1}) |
||
| 14 | |||
| 15 | Returns: |
||
| 16 | (Observable): observable instance. |
||
| 17 | |||
| 18 | """ |
||
| 19 | |||
| 20 | async def _subscribe(an_observer: Observer) -> Subscription: |
||
| 21 | for i in range(start, stop, step): |
||
| 22 | await an_observer.on_next(i) |
||
| 23 | await an_observer.on_completed() |
||
| 24 | |||
| 25 | return default_subscription |
||
| 26 | |||
| 27 | return rx_create(subscribe=_subscribe) |
||
| 28 |