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

Experiment: skip changes if component proto doesn't change #1134

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions mesop/web/src/component_renderer/component_renderer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {
ApplicationRef,
ChangeDetectionStrategy,
Component,
ComponentRef,
ElementRef,
HostListener,
Input,
SimpleChanges,
TemplateRef,
ViewChild,
ViewContainerRef,
Expand Down Expand Up @@ -59,6 +61,7 @@ const WEB_COMPONENT_PREFIX = '<web>';
MatDividerModule,
MatTooltipModule,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ComponentRenderer {
@ViewChild('childrenTemplate', {static: true})
Expand All @@ -69,7 +72,7 @@ export class ComponentRenderer {

@ViewChild('editorOverlay') editorOverlay!: TemplateRef<any>;

@Input() component!: ComponentProto;
@Input('component') component!: ComponentProto;
private _boxType: BoxType | undefined;
private _componentRef!: ComponentRef<BaseComponent>;
isEditorMode: boolean;
Expand Down Expand Up @@ -159,7 +162,14 @@ export class ComponentRenderer {
}
}

ngOnChanges() {
ngOnChanges(changes: SimpleChanges) {
// Note: this isn't a safe check necessarily.
if (
changes['component'].previousValue?.toString() ===
changes['component'].currentValue?.toString()
) {
return;
}
if (this.customElement) {
// Update the custom element properties and events
this.updateCustomElement(this.customElement);
Expand Down
Loading