Skip to content

Files implementation #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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