-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add dominator-rust template into tauri #576
base: dev
Are you sure you want to change the base?
Conversation
wasm-bindgen = "0.2.84" | ||
js-sys = "0.3.61" | ||
wasm-bindgen-futures= "0.4.34" | ||
gloo-events = "0.1.2" | ||
gloo-timers = { version = "0.2.6", features = ["futures"] } | ||
gloo-net = "0.2.6" | ||
wasm-logger = { version = "0.2.0", optional = true } | ||
serde-wasm-bindgen = "0.5.0" | ||
serde = "1.0.159" | ||
serde_json = "1.0.95" | ||
anyhow = "1.0.70" | ||
cfg-if = "1.0.0" | ||
log = "0.4.17" | ||
console_error_panic_hook = { version = "0.1.7", optional = true } | ||
futures = "0.3.28" | ||
dominator = "0.5.32" | ||
futures-signals = "0.3.32" | ||
once_cell = "1.17.1" | ||
dominator_helpers = "0.7.2" | ||
rand = "0.8.5" | ||
getrandom = { version = "0.2.8", features = ["js"] } | ||
ed25519-dalek = {version = "2.0.0-rc.3", features = ["serde", "rand_core"]} | ||
hex = "0.4.3" | ||
|
||
[dependencies.web-sys] | ||
version = "0.3.61" | ||
features = [ | ||
"console", | ||
"MouseEvent", | ||
"Document", | ||
"Element", | ||
"HtmlAnchorElement", | ||
"HtmlElement", | ||
"HtmlButtonElement", | ||
"HtmlImageElement", | ||
"Node", | ||
"Window", | ||
"Performance", | ||
"HtmlFormElement", | ||
] | ||
[features] | ||
default = [] | ||
dev = ["wasm-logger", "console_error_panic_hook"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a huge amount of dependencies, are these all required or can we simplify this a bit?
devPath = http://localhost:1420 | ||
distDir = ../dist | ||
withGlobalTauri = true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should also provide a beforeDevCommand
and beforeBuildCommand
@@ -0,0 +1,20 @@ | |||
{ | |||
"name": "{% package_name %}-ui", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the use of a package.json
file in a Rust project? we should remove this file
async fn invoke(cmd: &str, name: JsValue) -> JsValue; | ||
|
||
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "{% if alpha %}core{% else %}tauri{% endif %}"], js_name = invoke)] | ||
async fn invoke2(cmd: &str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this variant here
#[derive(Clone, Serialize, Deserialize)] | ||
struct Args { | ||
name: String, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename to GreetArgs so it can be consistent with other Rust templates
#[derive(Clone, Serialize, Deserialize)] | |
struct Args { | |
name: String, | |
} | |
#[derive(Serialize, Deserialize)] | |
struct GreetArgs<'a> { | |
name: &'a str, | |
} |
// let new_msg = | ||
// invoke("greet", to_value(&GreetArgs { name: &name.get() }).unwrap()).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment should be removed?
html!("div", { | ||
.child(html!("div", { | ||
.class(["body"]) | ||
.child(html!("div", { | ||
.text("Welcome to the Tauri + Dominator starter template.") | ||
})) | ||
})) | ||
.child(html!("div", { | ||
.children(&mut [ | ||
html!("input" => HtmlInputElement, { | ||
.prop_signal("value", state.input.signal_cloned()) | ||
|
||
.with_node!(element => { | ||
.event(clone!(app => move |_: events::Input| { | ||
log::info!("input: {}", element.value()); | ||
app.input.set(element.value()); | ||
})) | ||
}) | ||
}), | ||
|
||
html!("button", { | ||
.text("Greet") | ||
.event(clone!(app => move |_: events::Click| { | ||
let app = app.clone(); | ||
let input = app.input.lock_ref(); | ||
|
||
if *input == "" { | ||
app.clone().greet.set(None); | ||
|
||
} else { | ||
|
||
let input = input.to_string(); | ||
let args = Args {name: input.clone()}; | ||
let app = app.clone(); | ||
spawn_local(async move { | ||
let name = invoke("greet", to_value(&args).unwrap()).await; | ||
app.greet.set(name.as_string()); | ||
}); | ||
} | ||
})) | ||
}), | ||
|
||
html!("div", { | ||
.text_signal(app.greet.signal_ref(|greet| format!("{}", greet.clone().unwrap_or_default()))) | ||
}), | ||
|
||
html!("button", { | ||
.text("Greet2") | ||
.event(clone!(app => move |_: events::Click| { | ||
let app = app.clone(); | ||
let input = app.input.lock_ref(); | ||
|
||
if *input == "" { | ||
app.clone().greet.set(None); | ||
|
||
} else { | ||
|
||
let input = input.to_string(); | ||
let args = Args {name: input.clone()}; | ||
let app = app.clone(); | ||
spawn_local(async move { | ||
invoke2("greet2").await; | ||
// app.greet.set(name.as_string()); | ||
}); | ||
} | ||
})) | ||
}), | ||
|
||
html!("div", { | ||
.text_signal(app.greet.signal_ref(|greet| format!("{}", greet.clone().unwrap_or_default()))) | ||
}), | ||
|
||
]) | ||
})) | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init_logger(); | ||
std::panic::set_hook(Box::new(on_panic)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove all things related to loggings and keep the template as simple as possible
Hi @amrbashir , thank you for your input, very appreciate it. I'll address one by one soon. Just fyi on couple of things:
Thanks. |
Would like to hear more about this, as this would be a bug that needs to be fixed.
I would say this is an optimization for said larger projects to do, for create-tauri-app use-case, I'd like to keep the template as simple as possible so it is easier to add and modify later on. |
Adding dominator-rust project to create-tauri-app