clear_variables
This commit is contained in:
parent
a299ae1082
commit
4807b1bde5
6 changed files with 98 additions and 27 deletions
|
@ -1,6 +1,9 @@
|
|||
use zoon::{*, println};
|
||||
use crate::STORE;
|
||||
use zoon::*;
|
||||
|
||||
#[wasm_bindgen(inline_js = r#"export function strict_eval(code) { return eval?.(`"use strict"; ${code};`) }"#)]
|
||||
#[wasm_bindgen(
|
||||
inline_js = r#"export function strict_eval(code) { "use strict"; return eval?.(`${code}`) }"#
|
||||
)]
|
||||
extern "C" {
|
||||
#[wasm_bindgen(catch)]
|
||||
pub fn strict_eval(code: &str) -> Result<JsValue, JsValue>;
|
||||
|
@ -11,11 +14,14 @@ pub struct FW;
|
|||
|
||||
#[wasm_bindgen]
|
||||
impl FW {
|
||||
pub fn do_something() {
|
||||
println!("Command result: {:#?}", strict_eval("FW.do_something_else();"));
|
||||
pub fn say_hello() -> String {
|
||||
"Hello!".to_owned()
|
||||
}
|
||||
|
||||
pub fn do_something_else() {
|
||||
println!("ELSE!");
|
||||
pub fn clear_variables() -> String {
|
||||
let mut vars = STORE.selected_var_refs.lock_mut();
|
||||
let var_count = vars.len();
|
||||
vars.clear();
|
||||
format!("{var_count} variables cleared")
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue