|
| 1 | +use async_std::channel::unbounded; |
1 | 2 | use dwn_rs_core::{ |
2 | 3 | emitter::EventStreamer, subscription::SubscriptionFn, MapValue, |
3 | 4 | MessageEvent as CoreMessageEvent, |
4 | 5 | }; |
5 | 6 | use js_sys::Promise; |
6 | | -use tokio::sync::mpsc::unbounded_channel; |
7 | 7 | use tracing::{instrument, trace}; |
8 | 8 | use wasm_bindgen::prelude::*; |
9 | 9 | use wasm_bindgen_futures::{spawn_local, JsFuture}; |
@@ -71,10 +71,10 @@ async fn subscription_for_func( |
71 | 71 | listener: js_sys::Function, |
72 | 72 | ) -> Result<SubscriptionFn, JsError> { |
73 | 73 | trace!("creating subscription for js function"); |
74 | | - let (tx, mut rx) = unbounded_channel::<(String, CoreMessageEvent, MapValue)>(); |
| 74 | + let (tx, rx) = unbounded::<(String, CoreMessageEvent, MapValue)>(); |
75 | 75 |
|
76 | 76 | spawn_local(async move { |
77 | | - while let Some((tenant, evt, indexes)) = rx.recv().await { |
| 77 | + while let Ok((tenant, evt, indexes)) = rx.recv().await { |
78 | 78 | trace!( |
79 | 79 | tenant = ?tenant, |
80 | 80 | indexes = ?indexes, |
@@ -102,7 +102,7 @@ async fn subscription_for_func( |
102 | 102 | id, |
103 | 103 | Box::new(move |tenant, evt, indexes| { |
104 | 104 | trace!("sending event to listener"); |
105 | | - tx.send((tenant, evt, indexes)).unwrap_throw(); |
| 105 | + tx.send_blocking((tenant, evt, indexes)).unwrap_throw(); |
106 | 106 | }), |
107 | 107 | ); |
108 | 108 |
|
|
0 commit comments