Skip to content

refactor(cdk/tree): simplify code in lifecycle hooks #28124

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

Merged

Conversation

zarend
Copy link
Contributor

@zarend zarend commented Nov 14, 2023

Refactor CdkTree implementation to simplify code in lifecycle hooks. Create a RenderingData type definition to simplify the Tree's rendering pipeline.

The render pipeline looks like this. It has two entry points ngAfterContentChecked and whener the datasource is switched.

  1. ngAfterContentChecked OR datasource changed

  2. call _subscribeToDataChanges

From here, the pipeline diverges. Tree subscribes to changes in the datasource and expansion state. From there, the pipeline goes on two paths: emit changes to expansion state, and render the changes from the datasource.

Add RenderingData type to make it more clear what stages are in the pipeline.

This commit message will be squashed away.

Refactor CdkTree implementation to simplify code in lifecycle hooks.
Create a RenderingData type definition to simplify the Tree's rendering
pipeline.

The render pipeline looks like this. It has two entry points
ngAfterContentChecked and whener the datasource is switched.

1. ngAfterContentChecked OR datasource changed

2. call _subscribeToDataChanges

From here, the pipeline diverges. Tree subscribes to changes in the
datasource and expansion state. From there, the pipeline goes on two
paths: emit changes to expansion state, and render the changes from the
datasource.

Add RenderingData type to make it more clear what stages are in the
pipeline.

This commit message will be squashed away.
@zarend zarend marked this pull request as ready for review November 14, 2023 22:42
@zarend
Copy link
Contributor Author

zarend commented Nov 14, 2023

@BobobUnicorn could you take a look at this please?

Here's what I'm trying to accomplish. Based on the PR feedback we've gotten in #27626, I'm making it so it's easier for the reader of the code to understand the rendering pipeline of CdkTree. I've reduced the number of lines of code in the lifecycle hooks. I also introduced a data type to create a more clear boundaries between the different stages of the pipeline.

@zarend zarend requested a review from BobobUnicorn November 14, 2023 22:44
@zarend zarend merged commit 372f9df into angular:cdk-tree-revamp Nov 15, 2023
@zarend zarend deleted the cdk-tree-revamp_render_pipeline branch November 15, 2023 00:01
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants