polish: clean up the web module

This commit is contained in:
Jonathan Kelley committed 2021-09-24 20:11:30 -04:00
1 parent 1464d2e0a7
commit 823adc0834
15 files changed
+144 -50

No files matched your search

+15 -1
View File
@@ -1,7 +1,18 @@
/// Configuration for the WebSys renderer for the Dioxus VirtualDOM.
///
/// This struct helps configure the specifics of hydration and render destination for WebSys.
///
/// # Example
/// ```rust, ignore
/// fn main() {
/// dioxus::web::launch(App, |cfg| cfg.hydrate(true).root_name("myroot"))
/// }
/// ```
pub struct WebConfig {
pub(crate) hydrate: bool,
pub(crate) rootname: String,
}
impl Default for WebConfig {
fn default() -> Self {
Self {
@@ -10,6 +21,7 @@ impl Default for WebConfig {
}
}
}
impl WebConfig {
/// Enable SSR hydration
///
@@ -17,12 +29,14 @@ impl WebConfig {
/// work and suspended nodes.
///
/// Dioxus will load up all the elements with the `dio_el` data attribute into memory when the page is loaded.
///
pub fn hydrate(mut self, f: bool) -> Self {
self.hydrate = f;
self
}
/// Set the name of the element that Dioxus will use as the root.
///
/// This is akint to calling React.render() on the element with the specified name.
pub fn rootname(mut self, name: impl Into<String>) -> Self {
self.rootname = name.into();
self