File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ description = "Wrapper around reqwest for use in both native and wasm"
14
14
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
15
15
16
16
[dependencies ]
17
+ futures = " 0.3.28"
17
18
reqwest = { version = " 0.12.3" , default-features = false }
18
19
19
20
# For native compilation
@@ -27,7 +28,6 @@ js-sys = { version = "0.3.69", optional = true }
27
28
web-sys = { version = " 0.3.69" , optional = true }
28
29
29
30
[dev-dependencies ]
30
- futures = " 0.3.28"
31
31
reqwest = { version = " 0.12.3" }
32
32
wasm-bindgen-test = " 0.3.34"
33
33
Original file line number Diff line number Diff line change @@ -75,4 +75,6 @@ pub use wrappers::fetch;
75
75
#[ cfg( feature = "yield_now" ) ]
76
76
pub use yield_:: yield_now;
77
77
78
+ pub use wrappers:: block_on;
79
+
78
80
pub use reqwest:: Client ; // Exported to make it easier to use without a second import and maintain semver
Original file line number Diff line number Diff line change 43
43
crate :: wasm:: fetch ( request, on_done) ;
44
44
}
45
45
46
+ /// Provides a cross platform compatible way to run an async function in a blocking fashion.
47
+ /// Intended for use in callbacks as this will block but call backs are not async so we need sync code
48
+ pub fn block_on < F > ( future : F ) -> F :: Output
49
+ where
50
+ F : std:: future:: Future + Send + ' static ,
51
+ F :: Output : Send + ' static ,
52
+ {
53
+ futures:: executor:: block_on ( future)
54
+ }
55
+
46
56
// TODO 3: Test link in documentation after pushing to main
You can’t perform that action at this time.
0 commit comments