Module workflow_wasm::options
source · Expand description
Helper trait for managing options struct which extends Object
ⓘ
// create MyOptions struct
#[wasm_bindgen]
extern "C" {
#[derive(Debug, Clone, PartialEq, Eq)]
#[wasm_bindgen(extends = js_sys::Object)]
pub type MyOptions;
}
impl OptionsTrait for MyOptions{}
//impl methods as you need
impl MyOptions{
/// Set title
pub fn title(self, title:&str)->Self{
self.set("title", JsValue::from(title))
}
/// Set active
pub fn active(self, active:bool)->Self{
self.set("active", JsValue::from(active))
}
}
// use MyOptions
let options = MyOptions::new()
.title("title text")
.active(true);