Skip to content

Commit

Permalink
🎨 Add hydrate function.
Browse files Browse the repository at this point in the history
  • Loading branch information
langyo committed Dec 26, 2023
1 parent 1a4a02c commit aa788b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/macro-types/src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ where
root: web_sys::Element,
states: <Self as DeclType>::AppStates,
) -> ::yew::prelude::AppHandle<Self::ClientApp>;
fn hydrate_with_root(
root: web_sys::Element,
states: <Self as DeclType>::AppStates,
) -> ::yew::prelude::AppHandle<Self::ClientApp>;
}

pub trait DeclType
Expand Down
12 changes: 12 additions & 0 deletions packages/macro/src/utils/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ pub fn root(input: DeriveApp) -> TokenStream {
}
).render()
}

fn hydrate_with_root(
root: web_sys::Element,
states: <#ident as ::hikari_boot::DeclType>::AppStates
) -> ::yew::prelude::AppHandle<<#ident as ::hikari_boot::Application>::ClientApp> {
::yew::Renderer::<<#ident as ::hikari_boot::Application>::ClientApp>::with_root_and_props(
root,
::hikari_boot::AppContextForClient {
states
}
).hydrate()
}
}
}
}

0 comments on commit aa788b9

Please sign in to comment.