mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
revision: use JSON compatible serializer (#2592)
This commit is contained in:
parent
9ca5396343
commit
4ccd9ffe19
1 changed files with 4 additions and 1 deletions
|
@ -4,6 +4,7 @@ use dioxus_html::document::{
|
||||||
};
|
};
|
||||||
use generational_box::{AnyStorage, GenerationalBox, UnsyncStorage};
|
use generational_box::{AnyStorage, GenerationalBox, UnsyncStorage};
|
||||||
use js_sys::Function;
|
use js_sys::Function;
|
||||||
|
use serde::Serialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
@ -109,7 +110,9 @@ impl Evaluator for WebEvaluator {
|
||||||
|
|
||||||
/// Sends a message to the evaluated JavaScript.
|
/// Sends a message to the evaluated JavaScript.
|
||||||
fn send(&self, data: serde_json::Value) -> Result<(), EvalError> {
|
fn send(&self, data: serde_json::Value) -> Result<(), EvalError> {
|
||||||
let data = match serde_wasm_bindgen::to_value::<serde_json::Value>(&data) {
|
let serializer = serde_wasm_bindgen::Serializer::json_compatible();
|
||||||
|
|
||||||
|
let data = match data.serialize(&serializer) {
|
||||||
Ok(d) => d,
|
Ok(d) => d,
|
||||||
Err(e) => return Err(EvalError::Communication(e.to_string())),
|
Err(e) => return Err(EvalError::Communication(e.to_string())),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue