-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
Blazor: In-memory state container as cascading parameter #27296
Comments
Thanks for sending this in, @lonix1. We will take a look at it. However, we're booked with a lot of high priority work right through the end of the year, so we won't be able to reach this until early 2023. It won't get lost tho! It will be on a tracking issue. |
No worries - I'm using the above to great effect. It may help others if offered as an alternative. |
Here's the @ShaunCurtis approach posted at SO. Reference: https://stackoverflow.com/a/74080605
Additional context is in the discussion on the SO comment Q&A. |
@lonix1 ... AFAICT, we already have this approach covered (generally anyway ... i.e., a state-providing cascaded component) at ... |
Yeah 🤔 ... That's close enough conceptually that we don't need to take action on this. This issue will remain associated with the topic on GitHub, so if devs select the View all page feedback link, they'll see this issue and can see the other example approaches/discussion from there. Thanks for writing in on it. 👍 |
"View all page feedback" link - amazingly useful feature. It's buried at the very bottom so I never noticed it until now. Thanks. |
Yeah ... I don't like what they did with that because it would have helped us probably HUNDREDS of times both with readers looking for things here and even US ... the doc 🐈🐈🐈 ... I've forgotten about it myself tucked way down there. Anyway ... that's where they want it, so that's where it will stay. |
I didn't notice the "Factor out the state preservation to a common location" section that you pointed me to, because it's only shown when choosing the blazor server option (I'm using wasm). If it covers the same idea as what I posted above, and is applicable to wasm as well, maybe it should appear for wasm too? |
Hummmmmmmm 🤔 ... Perhaps SO! 😄 I'll take a look. |
The specific use case for that section uses ... Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage ... for Blazor Server apps (which is now baked into the framework). In this case, it basically just falls back to the main topic on the approach for WASM at ... ASP.NET Core Blazor cascading values and parameters For the WASM scenario, the PU ... Steve IIRC ... only says the following in the topic ...
... because he didn't want to show an opinionated, general approach. I'll add a cross-link there to the cascading values/params topic, but we're still going to leave it up to the dev to implement the code on their own. |
I had never seen that section either. Having studied it I have the same issue as with the initial code in the SO question. It's cascading |
I can't second-guess Steve on that tho. What's there came directly from the product unit, so I must assume that that's what he wants devs to do in general cases. Of course, devs can take another ... leaner ... approach if that suits them. They felt good enough about the way |
Actually, it was Pranav who directly signed off on the changes, which were kind'a minimal really ... We can't ask Pranav btw ... he's not on this PU team any longer. Looking back further, it was Mackinnion who provided the major review feedback on ... ... from the content that IIRC Steve provided earlier. Still tho, I don't think I want to ping on this. If the PU is getting a number of PU requests for help on the matter, they'll let me know. For now, I'd like to stick with the View all page feedback for the discussion and approach concepts. We're crazy busy 🏃😅 with the .NET 7 release, then I have a huge block of work to do on the Blazor security node for all of EOY right thru 🎅 Day and around 🎆 Day, then ... major topic overhauls and updates for 23Q1 ⛰️⛏️😅. I'd like to have a lean backlog going forward. I'm 👂 from the PU if they want to provide more coverage on this particular aspect. |
I'll tell you what ... I'll compromise right now. Let's cross-link THIS ISSUE right in the topic section. That way, it will surface better for devs. At some point in the future ... next year! 😆 lol ... I'll ask Dan and Artak about it. |
The compromise is sensible. However note when reconsidering this next year/whenever: |
The topic went beyond it's original purpose when the "in-memory state provider" was added. In the beginning, it was just focused on when user state held in the browser's memory is lost. Now, it's unfortunately a bit scatter 🧠. I've added this issue to a tracking issue so that I make sure to discuss this with the PU early next year. |
[EDIT by guardrex: The current approach for the in-memory state container service is located at In-memory state container service.]
The "In-memory state container service" section shows a state container as a service.
For simple app-wide stuff, it is simpler to use a cascading value. I posted a related question (with working code) to StackOverflow. (UPDATE: "MrC" posted another very nice solution.)
For example, working code:
AppState.razor
App.razor
MyComponent.razor
It would be nice to have that as another section, e.g. "In-memory state container as cascading parameter".
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: