From b46914528a46e1851361de0e8989787e00ac0172 Mon Sep 17 00:00:00 2001 From: frelodev Date: Wed, 14 Aug 2024 17:25:23 +0200 Subject: [PATCH] chore: updated js glue to have async send/recv --- src/ffi/js/buffer.rs | 4 ++-- src/ffi/js/cursor.rs | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ffi/js/buffer.rs b/src/ffi/js/buffer.rs index cdf3b0c..5f1b140 100644 --- a/src/ffi/js/buffer.rs +++ b/src/ffi/js/buffer.rs @@ -37,7 +37,7 @@ impl CodempBufferController { } #[napi(js_name = "send")] - pub fn js_send(&self, op: TextChange) -> napi::Result<()> { - Ok(self.send(op)?) + pub async fn js_send(&self, op: TextChange) -> napi::Result<()> { + Ok(self.send(op).await?) } } \ No newline at end of file diff --git a/src/ffi/js/cursor.rs b/src/ffi/js/cursor.rs index 3a83daf..11a524d 100644 --- a/src/ffi/js/cursor.rs +++ b/src/ffi/js/cursor.rs @@ -66,13 +66,14 @@ impl CodempCursorController { } #[napi(js_name = "send")] - pub fn js_send(&self, pos: JsCursor) -> napi::Result<()> { - Ok(self.send(crate::api::Cursor::from(pos))?) + pub async fn js_send(&self, pos: JsCursor) -> napi::Result<()> { + Ok(self.send(crate::api::Cursor::from(pos)).await?) } #[napi(js_name= "try_recv")] - pub fn js_try_recv(&self) -> napi::Result> { - Ok(self.try_recv()?.map(|x| JsCursor::from(x))) + pub async fn js_try_recv(&self) -> napi::Result> { + Ok(self.try_recv().await? + .map(|x| JsCursor::from(x))) } }