Skip to content
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

Renderer support for removing root components or updating parameters on them #34232

Merged
merged 6 commits into from
Jul 13, 2021

Conversation

SteveSandersonMS
Copy link
Member

This is needed as part of #27574

The core Renderer needs to have APIs for being told to:

  • Remove root components, clearing up properly and running all the correct disposal flows
  • Supply new parameters to root components, whether or not the rendering system is currently quiescent, and return a task that completes when we do reach quiescence

It's not necessary to add a new API for "supply new parameters" because the existing RenderRootComponentAsync actually does that already. The one thing it didn't support was being called while the system was not yet quiescent, so that's what I've added. It just involves juggling the tasks a little differently.

@SteveSandersonMS SteveSandersonMS requested a review from a team July 9, 2021 14:39
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Jul 9, 2021
@SteveSandersonMS SteveSandersonMS changed the title Renderer support for removing or updating parameters on root components Renderer support for removing root components or updating parameters on them Jul 9, 2021
// during a batch, but if a scenario emerges we can add support.
_batchBuilder.ComponentDisposalQueue.Enqueue(componentId);
_rootComponentsLatestParameters?.Remove(componentId);
ProcessRenderQueue();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this trigger the disposal of all the components in the tree? I remember having to do something more "sophisticated" here (triggering an empty render).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does - disposal is recursive. There's a unit test for that too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'm glad we found a simpler way, the way I did it was a bit convoluted

Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

I have to look at things with a fresh brain, but overall looks superb!

@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/renderer-removecomponent branch from 290cd0c to a92a11e Compare July 12, 2021 16:01
@SteveSandersonMS
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@SteveSandersonMS
Copy link
Member Author

@javiercn Is there anything further you want to check here, or is this good to merge? I'm asking because I have a subsequent PR building on this and it would be handy to target main with that rather than chaining PRs.

@@ -493,7 +493,7 @@ public async Task CreateBinder_NullableDateTimeOffset()
var expectedValue = new DateTime(2018, 3, 4, 1, 2, 3);

// Act
await binder.InvokeAsync(new ChangeEventArgs() { Value = expectedValue.ToString(CultureInfo.InvariantCulture), });
await binder.InvokeAsync(new ChangeEventArgs() { Value = expectedValue.ToString(CultureInfo.CurrentCulture), });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be unrelated, won't CurrentCulture cause issues with machines on other locales?

Copy link
Member Author

@SteveSandersonMS SteveSandersonMS Jul 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was wrong before. Binding works with culture-specific values. The parsing was already culture-specific, so it was incorrect to test a culture-invariant input, and was failing on my machine (using months for days, and vice-versa).

The only reason it was passing in CI before was due to the cultural imperialism of CultureInfo.InvariantCulture being equivalent to US date formatting. It should now work on all machines, each of them doing both formatting and parsing with their own local formatting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the cultural imperialism of CultureInfo.InvariantCulture being equivalent to US date formatting

lol, fair enough :).

I only brought it up because we ran into issues in the past in this area.

Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@SteveSandersonMS SteveSandersonMS merged commit a017f74 into main Jul 13, 2021
@SteveSandersonMS SteveSandersonMS deleted the stevesa/renderer-removecomponent branch July 13, 2021 12:00
@ghost ghost added this to the 6.0-preview7 milestone Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants