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

feat: Support loader function as input for route component #97

Open
brandonroberts opened this issue May 31, 2022 · 3 comments
Open

feat: Support loader function as input for route component #97

brandonroberts opened this issue May 31, 2022 · 3 comments

Comments

@brandonroberts
Copy link
Collaborator

Loaders can be used to fetch data for the component, run checks such as auth, redirect, and more.

import { Component } from '@angular/core';

@Component({
  template: `
    <router>
      <route path="/lazy"
        [load]="components.lazy"
        [loader]="() => Promise<Response> | Observable<Response>">
      </route>
    </router>
  `,
})
export class MyComponent {
  data$: Observable<Data> = getLoaderData();

  constructor(private loaderData$: LoaderData) {}

  components = {
    lazy: () => import('./lazy/lazy.component')
  };
}
@mainawycliffe
Copy link

@brandonroberts I am looking to familiarize myself with the inner working of this project, would you mind if I took a crack at this.

@brandonroberts
Copy link
Collaborator Author

Cool @mainawycliffe. You're welcome to, but I wouldn't put too much effort into it at the moment. I'm still evaluating this vs alternative options for routing

@mainawycliffe
Copy link

@brandonroberts Thanks. That looks interesting, will take a look while I get a chance. If it's what I think it is, I am really looking forward to it.

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

No branches or pull requests

2 participants