• Stars
    star
    4,677
  • Rank 8,584 (Top 0.2 %)
  • Language
    Python
  • License
    MIT License
  • Created about 11 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ReactiveX for Python

The ReactiveX for Python (RxPY)

Build Status Coverage Status PyPY Package Version Documentation Status

A library for composing asynchronous and event-based programs using observable collections and query operator functions in Python

ReactiveX for Python v4

For v3.X please go to the v3 branch.

ReactiveX for Python v4.x runs on Python 3.7 or above. To install:

pip3 install reactivex

About ReactiveX

ReactiveX for Python (RxPY) is a library for composing asynchronous and event-based programs using observable sequences and pipable query operators in Python. Using Rx, developers represent asynchronous data streams with Observables, query asynchronous data streams using operators, and parameterize concurrency in data/event streams using Schedulers.

import reactivex as rx
from reactivex import operators as ops

source = rx.of("Alpha", "Beta", "Gamma", "Delta", "Epsilon")

composed = source.pipe(
    ops.map(lambda s: len(s)),
    ops.filter(lambda i: i >= 5)
)
composed.subscribe(lambda value: print("Received {0}".format(value)))

Learning ReactiveX

Read the documentation to learn the principles of ReactiveX and get the complete reference of the available operators.

If you need to migrate code from RxPY v1.x or v3.x, read the migration section.

There is also a list of third party documentation available here.

Community

Join the conversation on GitHub Discussions! if you have any questions or suggestions.

Differences from .NET and RxJS

ReactiveX for Python is a fairly complete implementation of Rx with more than 120 operators, and over 1300 passing unit-tests. RxPY is mostly a direct port of RxJS, but also borrows a bit from Rx.NET and RxJava in terms of threading and blocking operators.

ReactiveX for Python follows PEP 8, so all function and method names are snake_cased i.e lowercase with words separated by underscores as necessary to improve readability.

Thus .NET code such as:

var group = source.GroupBy(i => i % 3);

need to be written with an _ in Python:

group = source.pipe(ops.group_by(lambda i: i % 3))

With ReactiveX for Python you should use named keyword arguments instead of positional arguments when an operator has multiple optional arguments. RxPY will not try to detect which arguments you are giving to the operator (or not).

Development

This project is managed using Poetry. Code is formatted using Black, isort. Code is statically type checked using pyright and mypy.

If you want to take advantage of the default VSCode integration, then first configure Poetry to make its virtual environment in the repository:

poetry config virtualenvs.in-project true

After cloning the repository, activate the tooling:

poetry install
poetry run pre-commit install

Run unit tests:

poetry run pytest

Run code checks (manually):

poetry run pre-commit run --all-files

More Repositories

1

RxJava

RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.
Java
47,636
star
2

rxjs

A reactive programming library for JavaScript
TypeScript
30,172
star
3

RxSwift

Reactive Programming in Swift
Swift
24,144
star
4

RxAndroid

RxJava bindings for Android
Java
19,863
star
5

RxKotlin

RxJava bindings for Kotlin
Kotlin
6,997
star
6

RxGo

Reactive Extensions for the Go language.
Go
4,840
star
7

rxdart

The Reactive Extensions for Dart
Dart
3,336
star
8

RxCpp

Reactive Extensions for C++
C++
2,949
star
9

RxPHP

Reactive extensions for PHP
PHP
1,680
star
10

learnrx

A series of interactive exercises for learning Microsoft's Reactive Extensions Library for Javascript.
JavaScript
1,403
star
11

RxNetty

Reactive Extension (Rx) Adaptor for Netty
Java
1,383
star
12

IxJS

The Interactive Extensions for JavaScript
TypeScript
1,284
star
13

RxRuby

Reactive Extensions for Ruby
Ruby
959
star
14

RxScala

RxScala – Reactive Extensions for Scala – a library for composing asynchronous and event-based programs using observable sequences
Scala
885
star
15

RxJavaFX

RxJava bindings for JavaFX
Java
517
star
16

RxRust

The Reactive Extensions for the Rust Programming Language
Rust
478
star
17

RxClojure

RxJava bindings for Clojure
Clojure
359
star
18

rxjs-tslint

TSLint rules targeting RxJS
TypeScript
308
star
19

RxJavaReactiveStreams

Adapter between RxJava and ReactiveStreams
Java
234
star
20

RxJavaDebug

Java
162
star
21

rxjs-docs

The home for new work on the new RxJS docs (RxJS v 5 and up). New to this space? Say hi here: https://github.com/ReactiveX/rxjs-docs/issues/24. Want to find out what's up? We're chatting here. https://github.com/ReactiveX/rxjs-docs/issues/4
TypeScript
161
star
22

RxGroovy

RxJava bindings for Groovy
Groovy
156
star
23

reactivex.github.io

ReactiveX Website
JavaScript
139
star
24

RxJavaAsyncUtil

Java
132
star
25

RxJavaString

Java
130
star
26

RxApacheHttp

RxJava bindings for Apache HTTP
Java
118
star
27

RxJavaJoins

Java
100
star
28

RxSwing

RxJava bindings for Swing
Java
97
star
29

RxJavaMath

Math operators for RxJava.
Java
96
star
30

rxjs-advent-2018

RxJS 2018 Advent Calendar
TypeScript
91
star
31

rxjs-core-notes

Notes from RxJS core meetings
77
star
32

RxJavaFileUtils

File utilities with RxJava
Java
62
star
33

RxJavaComputationExpressions

Java
60
star
34

RxJavaGuava

Java
54
star
35

RxJavaParallel

Experimental Parallel Extensions for RxJava
Java
54
star
36

RxJRuby

RxJava bindings for JRuby
Ruby
37
star
37

Rx.NET

Rx.NET – Reactive Extensions for .NET – a library for composing asynchronous and event-based programs using observable sequences for the CLR.
31
star
38

RxQuasar

RxJava bindings for Quasar
Java
16
star
39

RxRoboVM

RxJava bindings for iOS
Java
7
star
40

BuildInfrastructure

Test project for the new build system.
Groovy
5
star
41

RxSwing2

Reactive bindings for Java 8 Swing on top of RxJava 2
4
star