Skip to content
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

wasm-bindgen runtime #12

Merged
merged 1 commit into from
Jun 8, 2020
Merged

Conversation

stoically
Copy link
Contributor

Thanks for xtra! Exactly what I was looking for.

The README states that xtra is runtime agnostic, but I couldn't find an easy way to use it in WASM without the tokio or async-std runtime feature, hence I added the wasm-bindgen support. Hope this is useful.

To run the example cargo install wasm-pack is required.

What's missing in this PR are the methods depending on time, like notify_later, but I'd be fine to file that as follow-up if the wasm-bindgen feature generally is something you want to support.

@Restioson
Copy link
Owner

Restioson commented Jun 8, 2020

Hey, thanks for the PR! Indeed, I definitely do want to support as many runtimes as possible to make xtra easy to use. async_std and tokio were just the only two that came to mind when I first wrote xtra. I also plan to add methods for smol, now that it has been released.

I assume when you say "methods depending on time, like notify_later" you mean notify_interval and notify_after? notify_later itself is just later relative to immediate notifications.

Otherwise, this PR looks good, and I am happy to merge :) It will probably be released alongside other additions such as compiling on stable and smol support in 0.3 soonish.

@stoically
Copy link
Contributor Author

I also plan to add methods for smol, now that it has been released.

That's super cool! Also looking forward to the WASM support in smol.

I assume when you say "methods depending on time, like notify_later" you mean notify_interval and notify_after? notify_later itself is just later relative to immediate notifications.

Yeah, sorry, that's what I meant. Just added support for notify_interval and notify_after using futures-timer with the latest force-push.

Looking forward to the 0.3 release - stable rust support is awesome :)

@Restioson
Copy link
Owner

Also looking forward to the WASM support in smol.

Wow, that sounds cool!

Just added support for notify_interval and notify_after using futures-timer with the latest force-push.

Okay, cool :) I will merge now then.

@Restioson Restioson merged commit 0788eae into Restioson:master Jun 8, 2020
@stoically stoically deleted the wasm-bindgen branch June 8, 2020 15:45
@Restioson
Copy link
Owner

I've edited some stuff around wasm-bindgen in this commit to remove default features (for better configurability). The tests still run and pass successfully for me. However, I have limited prior experience with wasm and wouldn't know if I have unwittingly made an error, so if you could look at it too that would be greatly appreciated!

@stoically
Copy link
Contributor Author

Looks good to me, I'll let you know if I encounter an issue. I'm curious, why did you disable default-features for wasm-bindgen but not for the other runtimes?

@Restioson
Copy link
Owner

Different reasons:

  • async_std would not compile without it. Turns out they have a cfg(feature = "default") on the task::spawn fn.
  • smol does not have any default features
  • and neither does tokio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants