chore: updated js glue to have async send/recv

This commit is contained in:
frelodev 2024-08-14 17:25:23 +02:00
parent 8806941a13
commit b46914528a
2 changed files with 7 additions and 6 deletions

View file

@ -37,7 +37,7 @@ impl CodempBufferController {
} }
#[napi(js_name = "send")] #[napi(js_name = "send")]
pub fn js_send(&self, op: TextChange) -> napi::Result<()> { pub async fn js_send(&self, op: TextChange) -> napi::Result<()> {
Ok(self.send(op)?) Ok(self.send(op).await?)
} }
} }

View file

@ -66,13 +66,14 @@ impl CodempCursorController {
} }
#[napi(js_name = "send")] #[napi(js_name = "send")]
pub fn js_send(&self, pos: JsCursor) -> napi::Result<()> { pub async fn js_send(&self, pos: JsCursor) -> napi::Result<()> {
Ok(self.send(crate::api::Cursor::from(pos))?) Ok(self.send(crate::api::Cursor::from(pos)).await?)
} }
#[napi(js_name= "try_recv")] #[napi(js_name= "try_recv")]
pub fn js_try_recv(&self) -> napi::Result<Option<JsCursor>> { pub async fn js_try_recv(&self) -> napi::Result<Option<JsCursor>> {
Ok(self.try_recv()?.map(|x| JsCursor::from(x))) Ok(self.try_recv().await?
.map(|x| JsCursor::from(x)))
} }
} }