File: _asobservable.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 (31 lines) | stat: -rw-r--r-- 821 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
29
30
31
from typing import Callable, Optional, TypeVar

from reactivex import Observable, abc

_T = TypeVar("_T")


def as_observable_() -> Callable[[Observable[_T]], Observable[_T]]:
    def as_observable(source: Observable[_T]) -> Observable[_T]:
        """Hides the identity of an observable sequence.

        Args:
            source: Observable source to hide identity from.

        Returns:
            An observable sequence that hides the identity of the
            source sequence.
        """

        def subscribe(
            observer: abc.ObserverBase[_T],
            scheduler: Optional[abc.SchedulerBase] = None,
        ) -> abc.DisposableBase:
            return source.subscribe(observer, scheduler=scheduler)

        return Observable(subscribe)

    return as_observable


__all__ = ["as_observable_"]