Skip to content

Commit

Permalink
use bindings types (#1588)
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx authored Feb 4, 2025
1 parent ae4eb9c commit 2df29e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
9 changes: 1 addition & 8 deletions bindings_wasm/src/conversation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,7 @@ impl Conversation {
self.inner_client.clone(),
self.group_id.clone(),
move |message| match message {
Ok(item) => {
let serialized = crate::to_value(&item);
if let Err(e) = serialized {
callback.on_error(JsError::from(e));
} else {
callback.on_item(serialized.expect("checked for err"))
}
}
Ok(item) => callback.on_message(item.into()),
Err(e) => callback.on_error(JsError::from(e)),
},
);
Expand Down
14 changes: 2 additions & 12 deletions bindings_wasm/src/conversations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,7 @@ impl Conversations {
self.inner_client.clone(),
conversation_type.map(Into::into),
move |message| match message {
Ok(item) => {
let conversation = Conversation::from(item);
callback.on_item(JsValue::from(conversation))
}
Ok(item) => callback.on_conversation(item.into()),
Err(e) => callback.on_error(JsError::from(e)),
},
);
Expand Down Expand Up @@ -450,14 +447,7 @@ impl Conversations {
self.inner_client.clone(),
conversation_type.map(Into::into),
move |message| match message {
Ok(m) => {
let serialized = crate::to_value(&m);
if let Err(e) = serialized {
callback.on_error(JsError::from(e));
} else {
callback.on_item(serialized.expect("checked for err"))
}
}
Ok(m) => callback.on_message(m.into()),
Err(e) => callback.on_error(JsError::from(e)),
},
);
Expand Down
7 changes: 6 additions & 1 deletion bindings_wasm/src/streams.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::conversation::Conversation;
use crate::messages::Message;
use std::{cell::RefCell, rc::Rc};
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsError;
Expand All @@ -14,7 +16,10 @@ extern "C" {

/// Js Fn to call on an item
#[wasm_bindgen(structural, method)]
pub fn on_item(this: &StreamCallback, item: JsValue);
pub fn on_message(this: &StreamCallback, item: Message);

#[wasm_bindgen(structural, method)]
pub fn on_conversation(this: &StreamCallback, item: Conversation);

/// Js Fn to call on error
#[wasm_bindgen(structural, method)]
Expand Down

0 comments on commit 2df29e2

Please sign in to comment.