Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jjeffcaii/reactor-rust
A prototype of reactor in Rust.
https://github.com/jjeffcaii/reactor-rust
reactive-streams reactivex reactor rust rxjava rxrust
Last synced: about 14 hours ago
JSON representation
A prototype of reactor in Rust.
- Host: GitHub
- URL: https://github.com/jjeffcaii/reactor-rust
- Owner: jjeffcaii
- License: apache-2.0
- Created: 2019-09-09T09:10:03.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-03T01:53:05.000Z (almost 5 years ago)
- Last Synced: 2024-10-31T11:40:30.327Z (6 days ago)
- Topics: reactive-streams, reactivex, reactor, rust, rxjava, rxrust
- Language: Rust
- Size: 61.5 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# reactor-rust
[![Crates.io](https://img.shields.io/crates/v/reactor_rs)](https://crates.io/crates/reactor_rs)
[![Crates.io](https://img.shields.io/crates/d/reactor_rs)](https://crates.io/crates/reactor_rs)
[![Build Status](https://travis-ci.com/jjeffcaii/reactor-rust.svg?branch=master)](https://travis-ci.com/jjeffcaii/reactor-rust)
[![License](https://img.shields.io/github/license/jjeffcaii/reactor-rust.svg)](https://github.com/jjeffcaii/reactor-rust/blob/master/LICENSE)
[![GitHub Release](https://img.shields.io/github/release-pre/jjeffcaii/reactor-rust.svg)](https://github.com/jjeffcaii/reactor-rust/releases)> reactor-rust is an implementation of the [Reactive-Streams](https://www.reactive-streams.org) in Rust.
It is under active development. **Do not use it in a production environment!**## Install
Add `reactor_rs = 0.0.3` in your `Cargo.toml`.
## Example
> Here are some basic example codes:
### Mono
```rust
extern crate reactor_rs;use reactor_rs::mono;
use reactor_rs::prelude::*;
use reactor_rs::schedulers;
use std::{thread, time::Duration};fn main() {
let result = mono::just(42)
.do_on_success(|n| {
println!(
"Answer to the Ultimate Question of Life, The Universe, and Everything: {}",
n
);
})
.subscribe_on(schedulers::new_thread())
.flatmap(|n| {
// flatmap async and sleep 500ms.
mono::success(move || {
thread::sleep(Duration::from_millis(500));
n * 2
})
.subscribe_on(schedulers::new_thread())
})
.map(|n| n * 2)
.block()
.unwrap()
.unwrap();
println!("now it should be {}: actual={}!", 42 * 4, result);
}
```