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

Provide example of using this crate #6

Open
tversteeg opened this issue Apr 8, 2023 · 2 comments
Open

Provide example of using this crate #6

tversteeg opened this issue Apr 8, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@tversteeg
Copy link

tversteeg commented Apr 8, 2023

I couldn't find any information on actually using this crate. An example script file or at least a snippet of using it somewhere would help a ton.

My use case (not sure if it fits the scope of the crate):

I'm trying to use it as a replacement for tokio::runtime::Runtime that will also work on the browser, but after constructing it and calling .spawn_pinned(..) on it, I'm unsure what to do with the runtime. "Normally" I would call .block_on(..) on this runtime in the main function, but that method seems to be missing..

@futursolo
Copy link
Member

I agree this crate should add more documentation / examples around how it should be used.

In general, tasks meant to be run with the prokio runtime should always be spawned to a worker thread and outputs / results should be obtained with channels. Prokio should not be used in the main thread as browser is always non-blocking and hence it does not provide a #[prokio::main] macro.

You can check out Yew's server renderer about how to use it: https://github.com/yewstack/yew/blob/master/packages/yew/src/server_renderer.rs#L203

@futursolo futursolo added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 9, 2023
@tversteeg
Copy link
Author

Good to know, thanks for the information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants