Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor .NET 8 - Does PersistentComponentState replace the requirement for an API in Interactive Auto Mode

$
0
0

I'm trying to understand the new .NET 8 features regarding Blazor. Right now I'm trying to create a Blazor app, which runs on Interactive Auto Mode (Server and WebAssembly).

At a lot of places, i read that for a WebAssembly app I need a web-api so the client is able to request and save data (which is kinda logically). But is this so with .NET 8 and the PersistentComponentState?

How I understood the PersistentComponentState, I am able to persist data into it, that I am able to retrieve after the initial render has happened. So as soon as the Webassembly version of my app is ready, it will rerender the page using the persisted data, instead of sending another HTTP-Request. Similar thing is done, when I have a child-component in interactive render mode and I pass data as a parameter to it. Am I correct?

Now I wonder, if this, when splitting up the components well, would mean, that I do not need a web-api anymore...Let's say I want to create a page, that loads data, gives me the possibility to completely edit said data offline, and then save it back into the database. My idea would be to create a parent component (server rendering only), which contains a save button and a child component (editor in interactive render mode).The child component would receive the data through a bound parameter. And the parent object loads the data from DBContext in its OnInitialized method and saves it in the Save() method triggered by the ButtonClicked.

I would be able to edit the data all day long, and as long as I have an internet connection when loading or saving the data, I would be totally fine, right? Just like I would in an old-fashioned WASM application with api...The server rendered parent-component handles the server-connection and data-management as needed, just like my client would run http-requests for getting and posting/putting the data as needed...

Do I miss something?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>