PolyMeilex / rfd

Rusty File Dialog
MIT License
524 stars 60 forks source link

How to actually use AsyncFileDialog in WASM? #163

Open JohnDowson opened 7 months ago

JohnDowson commented 7 months ago

I got a function, not in the main loop, that needs file from a user.

I used AsyncFilePicker with wasm_bindgen_futures::spawn_local. However, this leads to the function continuing to run past that point and straight into a data race, where the file picker always loses since it is scheduled at the next tick, and the outer function wants to return immediately. I tried to approach this problem with channels, but I can't block the thread to wait on one.

ManevilleF commented 5 months ago

using either crossbeam-channels or flume you can wait for the channel in a non blocking way with try_iter