Questions tagged [rx-py]

Reactive Extensions for Python

RxPY is a library for composing asynchronous and event-based programs using observable collections and LINQ-style query operators in Python.

RxPY is open sourced and available under the Apache License, Version 2.0

96 questions
4
votes
2 answers

ReactiveX (Rx) - Detecting Long Press Events

I am wondering what is the canonical approach to solve the following problem in Rx: Say I have two observables, mouse_down and mouse_up, whose elements represent mouse button presses. In a very simplistic scenario, if I wanted to detect a long…
kloffy
  • 2,928
  • 2
  • 25
  • 34
3
votes
1 answer

Python reactive programming conditional executions

I started learning about reactive programming in Python using the RxPy module. Now, I have a case where I would like to run different functions depending on the received elements. I've achieved it in a very straightforward approach from rx.subject…
wasp256
  • 5,943
  • 12
  • 72
  • 119
3
votes
0 answers

Infinite loop with asyncio and rxpy

Here is what I'm trying to achieve: Create 2 independent objects that return asynchronous messages Convert the messages in Observable The functions are long so each object is on a separate file. Here is the base structure of my objects: class…
Joseph
  • 209
  • 2
  • 11
3
votes
2 answers

How to delay event emission with rxpy/rxjs?

I've got two event streams. One is from an inductance loop, the other is an IP camera. Cars will drive over the loop and then hit the camera. I want to combine them if the events are within N milliseconds of each other (car will always hit the loop…
3
votes
1 answer

RxPy: How to create hot observable from external callback and subscribe multiple asynchronous processes?

I have a external service (ExternalDummyService) in which I register a callback. I want to create an observable from that callback and subscribe multiple asynchronous processes. Full code in pyfiddle:…
raul.vila
  • 1,984
  • 1
  • 11
  • 24
3
votes
1 answer

How to websocket.send() data from an async function

I'm learning asyncio and trying to figure out how to pass data from one async function to a websocket loop in another async function. In my scenario, data is POSTed to web API by some third party. I'd like to echo the POST data to connected…
C. Myles
  • 51
  • 1
  • 5
3
votes
1 answer

RxPY - flat_map emissions waits for next generator value

Hi! I'm trying to get my first RxPY project done, but I'm having some problems undestanding the behavior of flat_map in Python. In this project there is an Observable created from a generator (a Kafka consumer). It emits values when a message is…
3
votes
4 answers

Split words into alphabetic dictionary rxpy

I am learning RxPY , so I need to write some code which can split each word by its first character. The results must look something like this: {'a': ['a'], 't': ['the','the'], 'l': ['low','lazy']} What I've tried. from rx import Observable ,…
Alesha
  • 31
  • 2
3
votes
1 answer

Integrate reactive extensions and twisted, basic example?

I'm looking for a very basic example of how to use reactive extensions (RxPY) and Twisted. Here's a minimal hello application that uses Twisted to stream messages. def hello(): print 'Hello from the reactor loop!' print 'Lately I feel like…
Adam Hughes
  • 14,601
  • 12
  • 83
  • 122
2
votes
1 answer

Create an interval and countdown using rxpy

I am making a Discord bot which allows you to create a poll. The user can put as an argument how long the poll will be. So I want to refresh every 5s or 10s (or maybe more) the message with the poll editing how much time the user has left. I want to…
Max García
  • 149
  • 1
  • 7
2
votes
1 answer

RxPy3 group_by creates "groupedobservables" but flat_map doesn't work - Reactive Python for Data Science Refactor

On deciding to learn RxPy I took the free course Reactive Python for Data Science from O'Reilly I quickly realised that the code was written for Python 3.5 and RxPy2 so I forked the original repo and decided to learn by refactoring the code for…
brianlmerritt
  • 2,644
  • 1
  • 34
  • 39
2
votes
1 answer

Python RX 'from_' not found in 'Observable | Observable'

I'm wanting to setup a simple project with RX python. I'm running python 3. I've setup my project, and ran pip install rx which successfully installed rx. I checked this using pip show rx which printed: Name: Rx Version: 1.6.1 Summary: Reactive…
Thomas Cook
  • 4,371
  • 2
  • 25
  • 42
2
votes
1 answer

return a value from observable via rxpy

what's the elegant way to convert a rx.Observable object to a 'normal' object in a function? e.g.: def foo(): return rx.Observable.just('value').subscribe() >>> print(foo()) # expected: # value # however get: #…
xiang0x48
  • 621
  • 6
  • 20
2
votes
0 answers

RxPY buffer example using a closing selector function?

Looking for an example using RxPy where buffering is done with the use of a closing selector function to decide when to close the buffer. In my example I want to be able to close my buffer boundaries based on values seen in the observables data…
Robert
  • 21
  • 2
2
votes
1 answer

RxPy passing value to observer

Is there a way to pass value to observer according to user input (which means that the value being passed is not fixed all the time)? from rx import Observable, Observer def push_five_strings(observer,value): observer.on_next(value) …
Kim SuYu
  • 69
  • 1
  • 11