Skip to content

Commit 6cec79e

Browse files
rylevrichard-uk1
andcommitted
Add implementation for rfc-1 (files)
Co-authored-by: Ryan Levick <[email protected]> Co-authored-by: Richard Dodd <[email protected]>
1 parent f9b1727 commit 6cec79e

File tree

12 files changed

+827
-13
lines changed

12 files changed

+827
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
Cargo.lock
44

55
guide/book
6+
.vscode

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ categories = ["api-bindings", "wasm"]
1414
gloo-timers = { version = "0.2.0", path = "crates/timers" }
1515
gloo-console-timer = { version = "0.1.0", path = "crates/console-timer" }
1616
gloo-events = { version = "0.1.0", path = "crates/events" }
17+
gloo-file = { version = "0.1.0", path = "crates/file" }
1718

1819
[features]
1920
default = []
20-
futures = ["gloo-timers/futures"]
21+
futures = ["gloo-timers/futures", "gloo-file/futures"]
2122

2223
[workspace]

crates/events/tests/web.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
#![cfg(target_arch = "wasm32")]
44

5-
use futures::prelude::*;
65
use futures::channel::mpsc;
6+
use futures::prelude::*;
77
use gloo_events::{EventListener, EventListenerOptions, EventListenerPhase};
88
use js_sys::Error;
99
use wasm_bindgen::{JsCast, JsValue, UnwrapThrowExt};
@@ -86,7 +86,8 @@ async fn new_with_options() {
8686

8787
body.click();
8888
body.click();
89-
}).await;
89+
})
90+
.await;
9091
assert_eq!(results, Ok(vec![(), ()]));
9192
}
9293

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

114115
body.click();
115116
body.click();
116-
}).await;
117+
})
118+
.await;
117119
assert_eq!(results, Ok(vec![()]));
118120
}
119121

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

133135
body.click();
134136
body.click();
135-
}).await;
137+
})
138+
.await;
136139
assert_eq!(results, Ok(vec![(), ()]));
137140
}
138141

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

152155
body.click();
153156
body.click();
154-
}).await;
157+
})
158+
.await;
155159
assert_eq!(results, Ok(vec![()]));
156160
}
157161

@@ -205,6 +209,7 @@ async fn dynamic_registration() {
205209
drop(handler3);
206210

207211
body.click();
208-
}).await;
212+
})
213+
.await;
209214
assert_eq!(results, Ok(vec![1, 2, 2, 2, 3, 3]));
210215
}

crates/file/Cargo.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[package]
2+
name = "gloo-file"
3+
version = "0.1.0"
4+
authors = ["Rust and WebAssembly Working Group"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
wasm-bindgen = "0.2.54"
9+
js-sys = "0.3.31"
10+
gloo-events = { path = "../events", version = "0.1" }
11+
mime = { version = "0.3.13", optional = true }
12+
futures-channel = { version = "0.3", optional = true }
13+
14+
[dependencies.web-sys]
15+
version = "0.3.31"
16+
features = [
17+
"Blob",
18+
"File",
19+
"FileList",
20+
"FileReader",
21+
"HtmlInputElement",
22+
"BlobPropertyBag",
23+
"FilePropertyBag",
24+
"DomException",
25+
]
26+
27+
[dev-dependencies]
28+
futures_rs = { version = "0.3", package = "futures" }
29+
wasm-bindgen-test = "0.3.4"
30+
chrono = { version = "0.4.10", features = ["wasmbind"] }
31+
32+
[features]
33+
default = []
34+
futures = ["futures-channel"]

0 commit comments

Comments
 (0)