SSR as library#46935
Merged
Merged
Conversation
…ching. Allows the caller more control over fine-grained sync logic.
5 tasks
34b5b70 to
7a48877
Compare
|
Thank you for your API proposal. I'm removing the |
Member
Author
|
API proposal at #47018 |
javiercn
approved these changes
Mar 3, 2023
javiercn
reviewed
Mar 3, 2023
| /// <param name="store">The <see cref="IPersistentComponentStateStore"/> to restore the application state from.</param> | ||
| /// <param name="dispatcher">The <see cref="Dispatcher"/> corresponding to the components' renderer.</param> | ||
| /// <returns>A <see cref="Task"/> that will complete when the state has been restored.</returns> | ||
| public Task PersistStateAsync(IPersistentComponentStateStore store, Dispatcher dispatcher) |
Member
There was a problem hiding this comment.
I do not think we need this API. We are the only ones that can provide a ComponentStatePersistenceManager to the system. Or am I missing something here?
Member
Author
There was a problem hiding this comment.
It's a layering thing. The existing caller is in Microsoft.AspNetCore.Mvc.TagHelpers and it can't see the internals of M.A.Components. It's same reason that you added the other PersistStateAsync overload before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This will cover both #38114 and be a basis for passive rendering for Blazor United. It's like the older prerendering logic but tidied up and enabling more control over asynchrony/dispatch.
New public APIs
All new:
Added:
namespace Microsoft.AspNetCore.Components.Infrastructure; public class ComponentStatePersistenceManager { public Task PersistStateAsync(IPersistentComponentStateStore store, Renderer renderer) + public Task PersistStateAsync(IPersistentComponentStateStore store, Dispatcher dispatcher) }This addition is because the prerendering code no longer has a
Microsoft.AspNetCore.Components.RenderTree.Rendererinstance (because we don't want to expose the renderer internals), but it does have the associatedDispatcherwhich is all thatComponentStatePersistenceManageractually needs. We could mark the olderPersistStateAsyncAPI as obsolete but I don't know whether that would accomplish much. Opinions welcome.Performance
This PR removes one of the layers of buffering in the output. It no longer prerenders into a
ViewBuffer, but instead supplies anIHtmlContentobject that writes the components' HTML directly from theRenderTreeFramebuffer to the response'sTextWriter. On the surface that sounds likely to improve perf (less work, less copying going on), but it still warrants verifying. Using this new benchmark, running in the perf infrastructure, I got the following results:Conclusion: This PR has a marginal positive effect on performance, but only in the region of 3%. That's fine since the point of this PR isn't about perf but rather is to add a new public API and prepare us for the new Blazor United SSR features.