WIP: #170 #172
@ -19,8 +19,14 @@ __version__ = "2023.4.dev170"
|
|||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
|
from .behavior_subject import BehaviorSubject
|
||||||
|
from .interval import Interval
|
||||||
|
from .observable import Observable
|
||||||
|
from .subject import Subject
|
||||||
|
from .subscriber import Subscriber
|
||||||
|
from .subscription import Subscription
|
||||||
|
from .type import ObserverOrCallable
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
||||||
|
@ -21,6 +21,11 @@ from collections import namedtuple
|
|||||||
|
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
|
from .observer import Observer
|
||||||
|
from .operator import Operator
|
||||||
|
from .subscribable import Subscribable
|
||||||
|
from .unsubscribable import Unsubscribable
|
||||||
|
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||||
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
version_info = VersionInfo(major="2023", minor="4", micro="dev170")
|
||||||
|
@ -148,3 +148,27 @@ class ReactiveTestCase(unittest.TestCase):
|
|||||||
sub.unsubscribe()
|
sub.unsubscribe()
|
||||||
end = datetime.now()
|
end = datetime.now()
|
||||||
self.assertEqual(round((end - start).total_seconds()), wait)
|
self.assertEqual(round((end - start).total_seconds()), wait)
|
||||||
|
|
||||||
|
def test_interval_custom(self):
|
||||||
|
wait = 10
|
||||||
|
i = 0
|
||||||
|
n = 0
|
||||||
|
|
||||||
|
def callback(x: Observer):
|
||||||
|
nonlocal n
|
||||||
|
x.next(n)
|
||||||
|
n += 1
|
||||||
|
|
||||||
|
def test_sub(x):
|
||||||
|
nonlocal i
|
||||||
|
self.assertEqual(x, i)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
observable = Interval(1.0, callback)
|
||||||
|
sub = observable.subscribe(test_sub)
|
||||||
|
start = datetime.now()
|
||||||
|
|
||||||
|
time.sleep(wait)
|
||||||
|
sub.unsubscribe()
|
||||||
|
end = datetime.now()
|
||||||
|
self.assertEqual(round((end - start).total_seconds()), wait)
|
||||||
|
Loading…
Reference in New Issue
Block a user