mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-23 05:14:54 +01:00
feat: new fn for controllers
This commit is contained in:
parent
a99eee170d
commit
f29ea23c4e
2 changed files with 16 additions and 1 deletions
|
@ -22,7 +22,7 @@ impl BufferController {
|
|||
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
|
||||
match _controller.recv().await {
|
||||
Ok(event) => {
|
||||
tsfn.call(event, ThreadsafeFunctionCallMode::NonBlocking); //check this shit with tracing also we could use Ok(event) to get the error
|
||||
tsfn.call(event, ThreadsafeFunctionCallMode::NonBlocking); //check this with tracing also we could use Ok(event) to get the error
|
||||
},
|
||||
Err(crate::Error::Deadlocked) => continue,
|
||||
Err(e) => break tracing::warn!("error receiving: {}", e),
|
||||
|
@ -32,6 +32,11 @@ impl BufferController {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[napi(js_name = "try_recv")]
|
||||
pub async fn js_try_recv(&self) -> napi::Result<Option<TextChange>> {
|
||||
Ok(self.try_recv().await?)
|
||||
}
|
||||
|
||||
#[napi(js_name = "recv")]
|
||||
pub async fn js_recv(&self) -> napi::Result<TextChange> {
|
||||
Ok(self.recv().await?.into())
|
||||
|
@ -41,4 +46,9 @@ impl BufferController {
|
|||
pub async fn js_send(&self, op: TextChange) -> napi::Result<()> {
|
||||
Ok(self.send(op).await?)
|
||||
}
|
||||
|
||||
#[napi(js_name = "content")]
|
||||
pub async fn js_content(&self) -> napi::Result<String> {
|
||||
Ok(self.content().await?)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,4 +76,9 @@ impl CursorController {
|
|||
Ok(self.try_recv().await?
|
||||
.map(|x| JsCursor::from(x)))
|
||||
}
|
||||
|
||||
#[napi(js_name= "recv")]
|
||||
pub async fn js_recv(&self) -> napi::Result<JsCursor> {
|
||||
Ok(self.recv().await?.into())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue