File: _startswith.py

package info (click to toggle)
python-rx 4.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,056 kB
  • sloc: python: 39,070; javascript: 77; makefile: 24
file content (28 lines) | stat: -rw-r--r-- 689 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from typing import Callable, TypeVar

import reactivex
from reactivex import Observable

_T = TypeVar("_T")


def start_with_(*args: _T) -> Callable[[Observable[_T]], Observable[_T]]:
    def start_with(source: Observable[_T]) -> Observable[_T]:
        """Partially applied start_with operator.

        Prepends a sequence of values to an observable sequence.

        Example:
            >>> start_with(source)

        Returns:
            The source sequence prepended with the specified values.
        """
        start = reactivex.from_iterable(args)
        sequence = [start, source]
        return reactivex.concat(*sequence)

    return start_with


__all__ = ["start_with_"]