-
Notifications
You must be signed in to change notification settings - Fork 178
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
Promise support #72
Comments
This is still very much an open problem! We can either have our own wrapper, or (preferably?) we can maybe base ourselves on common futures crate if possible. I haven't yet got around to binding any |
@koute Considering there's a lot of requests to get Promises in, can we take just the generic futures part (so no http / timeout / interval) from the stdweb-io crate and move them into stdweb so Promises can be properly used in Rust? That's just a few lines of code then with not really a lot of magic involved. I could whip up an experimental PR to explore how this would look like. |
@CryZe Right, I was just about to mentoin your |
@koute My opinion is that In other words, I think |
@Pauan Yep. That's also what I think. But sometimes the original JS API doesn't translate very well to Rust in its unmodified form (like, for example, As I've said, I haven't explored the problem space yet at all so I simply can't tell you what I think would be best to do here. (A lot of stuff in |
I think there should definitely be a 1:1 Promise API as much as possible. Assuming we can have a 1:1 Promise API, we can then build an optional tiny wrapper on top that translates a Promise into a Rust future so we gain Rust's async await syntax and all of the futures crate's future combinators. So we have all of the JavaScript APIs available, but also full on compatibility with the Rust world. It may make sense to keep that tiny wrapper in a different crate, but it's so tiny that I think it may make sense to be part of stdweb, just because it gives you so much compatibility with the eco system, additional async await syntax, a ton of combinators, ... all with very little effort. |
@CryZe That sounds reasonable to me. I'm definitely fine with having a built in "compatibility" wrapper like that to interact with the rest of the Rust ecosystem. We already have some support for |
^ Title
The text was updated successfully, but these errors were encountered: