{"id":13484821,"url":"https://github.com/rxRust/rxRust","last_synced_at":"2025-03-27T16:31:21.829Z","repository":{"id":37549745,"uuid":"187421513","full_name":"rxRust/rxRust","owner":"rxRust","description":"Rust implementation of Reactive Extensions. ","archived":false,"fork":false,"pushed_at":"2023-09-26T12:25:29.000Z","size":1075,"stargazers_count":844,"open_issues_count":9,"forks_count":59,"subscribers_count":28,"default_branch":"master","last_synced_at":"2023-09-26T16:18:33.691Z","etag":null,"topics":["reactivex","rx","rxrs","rxrust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rxRust.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-05-19T01:32:49.000Z","updated_at":"2023-10-20T12:21:52.676Z","dependencies_parsed_at":"2022-07-12T16:22:52.931Z","dependency_job_id":"7128559c-efc6-4ea8-9d38-781f07c3200e","html_url":"https://github.com/rxRust/rxRust","commit_stats":{"total_commits":560,"total_committers":32,"mean_commits":17.5,"dds":0.4464285714285714,"last_synced_commit":"6d1f059f55789d8e2dbb334a87ec5ccdf356953d"},"previous_names":[],"tags_count":26,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxRust%2FrxRust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxRust%2FrxRust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxRust%2FrxRust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxRust%2FrxRust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxRust","download_url":"https://codeload.github.com/rxRust/rxRust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245882387,"owners_count":20687877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["reactivex","rx","rxrs","rxrust"],"created_at":"2024-07-31T17:01:34.898Z","updated_at":"2025-03-27T16:31:21.406Z","avatar_url":"https://github.com/rxRust.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# rxRust: a Rust implementation of Reactive Extensions\n[![](https://docs.rs/rxrust/badge.svg)](https://docs.rs/rxrust/)\n[![codecov](https://codecov.io/gh/rxRust/rxRust/branch/master/graph/badge.svg)](https://codecov.io/gh/rxRust/rxRust)\n![](https://github.com/rxRust/rxRust/workflows/test/badge.svg)\n[![](https://img.shields.io/crates/v/rxrust.svg)](https://crates.io/crates/rxrust)\n[![](https://img.shields.io/crates/d/rxrust.svg)](https://crates.io/crates/rxrust)\n\n## Usage\n\nAdd this to your Cargo.toml:\n\n```toml\n[dependencies]\nrxrust = \"1.0.0-beta.0\"\n```\n\n## Example \n\n```rust\nuse rxrust:: prelude::*;\n\nlet mut numbers = observable::from_iter(0..10);\n// create an even stream by filter\nlet even = numbers.clone().filter(|v| v % 2 == 0);\n// create an odd stream by filter\nlet odd = numbers.clone().filter(|v| v % 2 != 0);\n\n// merge odd and even stream again\neven.merge(odd).subscribe(|v| print!(\"{} \", v, ));\n// \"0 2 4 6 8 1 3 5 7 9\" will be printed.\n\n```\n\n## Clone Stream\n\nIn `rxrust` almost all extensions consume the upstream. So when you try to subscribe a stream twice, the compiler will complain. \n\n```rust ignore\n # use rxrust::prelude::*;\n let o = observable::from_iter(0..10);\n o.subscribe(|_| println!(\"consume in first\"));\n o.subscribe(|_| println!(\"consume in second\"));\n```\n\nIn this case, we must clone the stream.\n\n```rust\n # use rxrust::prelude::*;\n let o = observable::from_iter(0..10);\n o.clone().subscribe(|_| println!(\"consume in first\"));\n o.clone().subscribe(|_| println!(\"consume in second\"));\n```\n\nIf you want to share the same observable, you can use `Subject`.\n\n## Scheduler\n\n`rxrust` use the runtime of the `Future` as the scheduler, `LocalPool` and `ThreadPool` in `futures::executor` can be used as schedulers directly, and `tokio::runtime::Runtime` is also supported, but need to enable the feature `futures-scheduler`. Across `Scheduler` to implement custom `Scheduler`.\nSome Observable Ops (such as `delay`, and `debounce`) need the ability to delay, futures-time supports this ability when set with the `timer` feature, but you can also customize it by setting the new_timer function to NEW_TIMER_FN variant and removing the `timer` feature.\n```rust \nuse rxrust::prelude::*;\n\n// `FuturesThreadPoolScheduler` is the alias of `futures::executor::ThreadPool`.\nlet threads_scheduler = FuturesThreadPoolScheduler::new().unwrap();\n\nobservable::from_iter(0..10)\n  .subscribe_on(threads_scheduler.clone())\n  .map(|v| v*2)\n  .observe_on_threads(threads_scheduler)\n  .subscribe(|v| println!(\"{},\", v));\n```\n\nAlso, `rxrust` supports WebAssembly by enabling the feature `wasm-scheduler` and using the crate `wasm-bindgen`. A simple example is [here](https://github.com/utilForever/rxrust-with-wasm). \n\n## Converts from a Future\n\nJust use `observable::from_future` to convert a `Future` to an observable sequence.\n\n```rust\nuse rxrust::prelude::*;\n\nlet mut scheduler_pool = FuturesLocalSchedulerPool::new();\nobservable::from_future(std::future::ready(1), scheduler_pool.spawner())\n  .subscribe(move |v| println!(\"subscribed with {}\", v));\n\n// Wait `task` finish.\nscheduler_pool.run();\n```\n\nA `from_future_result` function is also provided to propagate errors from `Future``.\n\n## Missing Features List\nSee [missing features](missing_features.md) to know what rxRust does not have yet.\n\n## All contributions are welcome\n\nWe are looking for contributors! Feel free to open issues for asking questions, suggesting features or other things!\n\nHelp and contributions can be any of the following:\n\n- use the project and report issues to the project issues page\n- documentation and README enhancement (VERY important)\n- continuous improvement in a ci Pipeline\n- implement any unimplemented operator, remember to create a pull request before you start your code, so other people know you are working on it.\n\nyou can enable the default timer by `timer` feature, or set a timer across function `new_timer_fn`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FrxRust%2FrxRust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FrxRust%2FrxRust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FrxRust%2FrxRust/lists"}