Skip to content

refactor(dashboards-ng): remove explicit editable$ subscribe in widget-host#1836

Open
chintankavathia wants to merge 1 commit intomainfrom
refactor/dashboards-ng/avoid/redundant-subscription
Open

refactor(dashboards-ng): remove explicit editable$ subscribe in widget-host#1836
chintankavathia wants to merge 1 commit intomainfrom
refactor/dashboards-ng/avoid/redundant-subscription

Conversation

@chintankavathia
Copy link
Copy Markdown
Member

@chintankavathia chintankavathia commented Apr 8, 2026

There is already | async in template so explicit subscription is not needed here.
Move setupEditable side effect into editable$ pipe via tap, leveraging the template's async pipe subscription instead of a manual subscribe in ngOnInit. Update editable$ access modifier to protected as it is meant to be used internally.


Documentation.
Examples.
Dashboards Demo.
Playwright report.

Coverage Reports:

Code Coverage

…t-host

Move setupEditable side effect into editable$ pipe via tap, leveraging the template's async pipe subscription instead of a manual subscribe in ngOnInit. Update editable$ access modifier to protected as it is meant to be used internally.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the editable state management in SiWidgetHostComponent by moving the setup logic into a pipe on the editable$ observable and removing the redundant subscription in ngOnInit. Additionally, it updates the configChange subscription to reference the grid service directly. I have provided a suggestion to improve the RxJS implementation by using withLatestFrom to make the data flow more declarative and to remove the unnecessary setTimeout.

@chintankavathia chintankavathia marked this pull request as ready for review April 8, 2026 12:22
@chintankavathia chintankavathia requested review from a team as code owners April 8, 2026 12:22
Comment on lines +90 to +92
protected editable$ = this.gridService.editable$.pipe(
tap(editable => this.setupEditable(editable))
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about using fromObservable here? And then making all the things calculated in setupEditable computed or linkedSignals?

I don't like that this depends on the async pipe in the template. What happens if someone later uses this a second time in the template? Then we have duplicated execution of setupEditable. So in that regard the current approach is better. But using `fromObservable might be even nicer...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants