Skip to content

QUESTION: Why is Intersection Observer and requestIdleCallback not used? #129

Description

@dianmonblan

Hello,

I think it can work like ngx-quicklink does using Intersection Observer and requestIdleCallback taking advantage of browser idle optimizing module download but now modeled to component download.

I recommend use Intersection Observer and requestIdleCallback with animationFrameScheduler for better performance on the browser.

Why is Intersection Observer and requestIdleCallback not used? Thanks for the reply and sorry for my poor english 😚

.pipe(
// This is used to coalesce changes since the `url$` subject might emit multiple values initially, e.g.
// `null` (initial value) and the url itself (when the `url` binding is provided).
// The `animationFrameScheduler` is used to prevent the frame drop.
debounceTime(0, animationFrameScheduler),
switchMap((url) => {
if (this.loadingTemplateRef) {
this.vcr.createEmbeddedView(this.loadingTemplateRef);
} else if (loadingComponent) {
const factory = this.cfr.resolveComponentFactory(loadingComponent);
this.vcr.createComponent(factory);
}
return from(
this.elementsLoaderService.loadElement(
url,
elementTag,
this.isModule,
this.importMap,
elementConfig?.hooks
)
).pipe(
catchError(() => {
this.vcr.clear();
const errorComponent =
elementConfig.errorComponent || options.errorComponent;
if (this.errorTemplateRef) {
this.vcr.createEmbeddedView(this.errorTemplateRef);
this.cdr.markForCheck();
} else if (errorComponent) {
const factory =
this.cfr.resolveComponentFactory(errorComponent);
this.vcr.createComponent(factory);
this.cdr.markForCheck();
} else if (ngDevMode) {
console.error(
`${LOG_PREFIX} - Loading of element <${elementTag}> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElement="errorTemplate: error" to display customized error message in place of element`
);
}
return EMPTY;
})
);
}),
mergeMap(() => customElements.whenDefined(elementTag))
)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions