-
Couldn't load subscription status.
- Fork 5
Description
Consider a case where you send a WS request and want to await a WS response
One way to do this that works right now is to:
loop {
// sleep
hyperware_process_lib::hyperapp::sleep(DELAY_MS).await;
if let Some(response) = response_map(id) {
// if response is here, handle it
}
}where id is registered with the request and when the response comes in it gets put into the response_map
It would be a lot nicer to, e.g.,
if let Some(response) = receiver.await {
}I think either way we need to have the user manage the registration of requests or else it will be enforcing a certain format on their messages.
E.g. in the case of spider:
Store as pending response
https://github.com/nick1udwig/spider/blob/ccb0605012976429f466763a1939cb9024f152a6/spider/src/lib.rs#L850
Handle response
https://github.com/nick1udwig/spider/blob/ccb0605012976429f466763a1939cb9024f152a6/spider/src/lib.rs#L1314
https://github.com/nick1udwig/spider/blob/ccb0605012976429f466763a1939cb9024f152a6/spider/src/lib.rs#L1458
Poll awaiting response
https://github.com/nick1udwig/spider/blob/ccb0605012976429f466763a1939cb9024f152a6/spider/src/lib.rs#L1550-L1579