Skip to content

Commit

Permalink
Experiment: skip changes if component proto doesn't change
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen committed Dec 6, 2024
1 parent 721219a commit ace642f
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit ace642f

Please sign in to comment.