File: frommarbles_lookup.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 (16 lines) | stat: -rw-r--r-- 520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import reactivex
import reactivex.operators as ops

"""
Use a dictionnary to convert elements declared in the marbles diagram to
the specified values.
"""

lookup0 = {"a": 1, "b": 3, "c": 5}
lookup1 = {"x": 2, "y": 4, "z": 6}
source0 = reactivex.cold("a---b----c----|", timespan=0.01, lookup=lookup0)
source1 = reactivex.cold("---x---y---z--|", timespan=0.01, lookup=lookup1)

observable = reactivex.merge(source0, source1).pipe(ops.to_iterable())
elements = observable.run()
print("received {}".format(list(elements)))