Skip to content

Commit

Permalink
Merge pull request #110 from derekdreery/files-implementation
Browse files Browse the repository at this point in the history
Files implementation
  • Loading branch information
Pauan committed Feb 18, 2020
2 parents f9b1727 + 6cec79e commit ce79166
Show file tree
Hide file tree
Showing 12 changed files with 827 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
Cargo.lock

guide/book
.vscode
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ categories = ["api-bindings", "wasm"]
gloo-timers = { version = "0.2.0", path = "crates/timers" }
gloo-console-timer = { version = "0.1.0", path = "crates/console-timer" }
gloo-events = { version = "0.1.0", path = "crates/events" }
gloo-file = { version = "0.1.0", path = "crates/file" }

[features]
default = []
futures = ["gloo-timers/futures"]
futures = ["gloo-timers/futures", "gloo-file/futures"]

[workspace]
17 changes: 11 additions & 6 deletions crates/events/tests/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#![cfg(target_arch = "wasm32")]

use futures::prelude::*;
use futures::channel::mpsc;
use futures::prelude::*;
use gloo_events::{EventListener, EventListenerOptions, EventListenerPhase};
use js_sys::Error;
use wasm_bindgen::{JsCast, JsValue, UnwrapThrowExt};
Expand Down Expand Up @@ -86,7 +86,8 @@ async fn new_with_options() {

body.click();
body.click();
}).await;
})
.await;
assert_eq!(results, Ok(vec![(), ()]));
}

Expand All @@ -113,7 +114,8 @@ async fn once_with_options() {

body.click();
body.click();
}).await;
})
.await;
assert_eq!(results, Ok(vec![()]));
}

Expand All @@ -132,7 +134,8 @@ async fn new() {

body.click();
body.click();
}).await;
})
.await;
assert_eq!(results, Ok(vec![(), ()]));
}

Expand All @@ -151,7 +154,8 @@ async fn once() {

body.click();
body.click();
}).await;
})
.await;
assert_eq!(results, Ok(vec![()]));
}

Expand Down Expand Up @@ -205,6 +209,7 @@ async fn dynamic_registration() {
drop(handler3);

body.click();
}).await;
})
.await;
assert_eq!(results, Ok(vec![1, 2, 2, 2, 3, 3]));
}
34 changes: 34 additions & 0 deletions crates/file/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "gloo-file"
version = "0.1.0"
authors = ["Rust and WebAssembly Working Group"]
edition = "2018"

[dependencies]
wasm-bindgen = "0.2.54"
js-sys = "0.3.31"
gloo-events = { path = "../events", version = "0.1" }
mime = { version = "0.3.13", optional = true }
futures-channel = { version = "0.3", optional = true }

[dependencies.web-sys]
version = "0.3.31"
features = [
"Blob",
"File",
"FileList",
"FileReader",
"HtmlInputElement",
"BlobPropertyBag",
"FilePropertyBag",
"DomException",
]

[dev-dependencies]
futures_rs = { version = "0.3", package = "futures" }
wasm-bindgen-test = "0.3.4"
chrono = { version = "0.4.10", features = ["wasmbind"] }

[features]
default = []
futures = ["futures-channel"]
Loading

0 comments on commit ce79166

Please sign in to comment.