jdtcn / HybridBlazor

Simultaneous Blazor Hosting Models and switching at runtime
MIT License
97 stars 24 forks source link

NET 6 Wasm Prerendered with persist state component vs HybridBlazor #5

Closed Krzysztof318 closed 2 years ago

Krzysztof318 commented 2 years ago

Hi, I like to know does you have plan to change solution to use new was prerender which is available in NET 6 and persist state component?

NET 6 Wasm prerendered has one disadvantage against your solution. Page is static until WASM is loaded, user can't interact. Did you analized it is possible use new NET 6 solution and have interaction when WASM is not loaded yet?

jdtcn commented 2 years ago

Hi,

PersistentComponentState is used in https://github.com/jdtcn/HybridBlazor/blob/715eeb0e0d2e2a113f37fad0f9595b57299b79ae/HybridBlazor/Client/Pages/FetchData.razor#L43

Prerendering enabled too https://github.com/jdtcn/HybridBlazor/blob/715eeb0e0d2e2a113f37fad0f9595b57299b79ae/HybridBlazor/Server/Pages/_Host.cshtml#L29

In general, the whole idea of the project is to have interaction when WASM is not loaded yet.

Krzysztof318 commented 2 years ago

Ok, thanks for replies.

Krzysztof318 commented 2 years ago

Hi, I have one question more. When blazor is using WebAsssemblyPrerendered then PersistentComponentState avoided execute ForecastService.GetForecastAsync when switched from static files to WASM. In your solution PersistentComponentState works only for server mode. When page is switched to WASM then ForecastService.GetForecastAsync is invoked again. Does it is possible to persist state with PersistentComponentState between server and wasm in your solution?

jdtcn commented 2 years ago

Surely this is possible, but it is hardly easy to do, I have not tried it. I don't understand why use WebAssemblyPrerendered because prerendering will already be done in ServerPrerendered mode.

You can also look towards the https://github.com/servicetitan/Stl.Fusion library if you need to manage complex state

Krzysztof318 commented 2 years ago

Thanks for help. Btw. I don't want to use WebAssemblyPrerendered. I puted this as example to compare with your solution.