-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Conversation
// during a batch, but if a scenario emerges we can add support. | ||
_batchBuilder.ComponentDisposalQueue.Enqueue(componentId); | ||
_rootComponentsLatestParameters?.Remove(componentId); | ||
ProcessRenderQueue(); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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!
Not regarding this as a breaking change, because it would never have been supported before to call the renderer from outside its sync context.
290cd0c
to
a92a11e
Compare
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
@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 |
@@ -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), }); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
This is needed as part of #27574
The core
Renderer
needs to have APIs for being told to: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.