-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Futures 0.3 + async/await syntax #1105
Comments
For the first part I think in theory you can use the conversions between JS promises and Rust futures to define everything in Rust, but you may run into snags to work through! For the second that looks related to the futures 0.1 and 0.3 shims perhaps, maybe a For the last part, we're waiting on 0.3 to run on stable Rust, but we'll update to that as soon as we can! In the meantime though having a |
Would anybody be willing to help me I am trying to create a PR for a version of the futures crate that would support futures0.3/async but running into some struggles. Would really like to be able to offer them even if is only for those using nightly for now. |
@corbinu Sure, I have a lot of experience with Futures (having ported my Signals crate from 0.1 to 0.3), so I can help. Personally, I think a |
@Pauan Sure let me create a fork and add you. Thanks I really want to release a few example crates using WASM that work both in Rust and Node. |
Bumped into this issue today. The solution is to pin the GenFuture like this future_to_promise(Compat::new(test().boxed())) |
Futures have stabilized in nightly! 🎊 |
Right, but we have to wait until it actually lands in the Stable compiler before we can use it. That'll probably be sometime in July. |
Thanks for the ping on this @steveklabnik, and I actually personally think we should go ahead and get this done. This would be behind an off-by-default feature gate to ensure that we don't regress current users of the @Pauan would you be ok with that strategy? |
@alexcrichton Yeah, that sounds great to me. |
Support for this has been implemented in #1507! |
To use Futures 0.3, first enable the [dependencies]
wasm-bindgen-futures = { version = "0.3.20", features = ["futures_0_3"] } Then import and use the use wasm_bindgen_futures::futures_0_3::{JsFuture, future_to_promise, spawn_local}; (You also have to wait for the new version of |
Any idea on when that release may happen? I'd like to give it a try! |
I've posted a new release at #1536 |
Hi again! I have a two-part question here.
First, I'm trying to work out how SPA routing could work with
wasm-bindgen
, where navigating to a new route requires fetching data from an API. Based on this conversation it sounds like the fetch request would need to be called by JS at some point, but I'm not sure what that should look like.Is this possible with just one
#[wasm_bindgen(start)]
function, or is more JS required?Second, I would like to use the new
async
/await!
syntax if possible but I'm running into compiler errors with my local experiments. Here's an example:I see errors like this:
I'm using
futures-preview = { version = "0.3.0-alpha.10", features = ["compat"] }
and trying to convert to a0.1
Future
thatwasm-bindgen-futures
can use and convert to aPromise
. I don't have a full grasp on futures/async/await in Rust so there's a good chance I'm doing something obviously wrong.Bonus question: has the futures
0.3
API stabilized enough that it could be supported? 😃Thanks for your time!
The text was updated successfully, but these errors were encountered: