Crates.io | promise-rs |
lib.rs | promise-rs |
version | 0.3.0 |
source | src |
created_at | 2017-03-16 00:32:21.703497 |
updated_at | 2017-04-09 10:56:33.568616 |
description | Rust Promise library |
homepage | |
repository | https://github.com/stan-kondrat/promise-rs |
max_upload_size | |
id | 8991 |
size | 11,088 |
Under the hood, executor spawn new thread at each time when Promise::new(executor)
invoked.
Documentation https://docs.rs/promise-rs
extern crate promise;
use promise::Promise;
fn main() {
let mut promise = Promise::new(|resolve, reject| {
// do something
let result: Option<String> = Some("resolve result".to_string());
resolve(result);
});
promise
.then(|value| { /* on fulfilled */ None }, |reason| { /* on rejected */ None })
.catch(|reason| { /* on rejected: */ None });
}
Best way to begin learning a new language is start write own library. As I came from front-end world, will create yet another Promise library for Rust.