async_rx.observable.rx_range   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A rx_range() 0 21 2
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