I am trying to connect DOM events with web_sys
, e.g. in a click handler set_onmousedown()
to functions that are async
, because they perform REST calls, which are async
(uses JavaScript Promise
s which are mapped to Rust Future
s.)
In most web_sys
examples this is done using non-asynchronous closures.
async
closure are only available in Rust nightly, but i shy away from this because i fear using nightly will open further problems.
Ideally i'd like to register a plain async
Rust function, but i don't see how.
Connecting a Function
works but Function
is !Sync
. This means, i can not hold them in e.g. lazy_static
and have to recreate them each time an event is triggered.
I don't see a satisfying solution. Any ideas?