Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Can we avoid repeating the same loadingComponent for each route? #142

Closed
frederikhors opened this issue Oct 3, 2020 · 3 comments
Closed
Labels
wontfix This will not be worked on

Comments

@frederikhors
Copy link
Contributor

I'm using the new 3 version.

I have these routes:

import { wrap } from "svelte-spa-router/wrap";

import RouteLoading from "./RouteLoading.svelte";
import RouteNotFound from "./RouteNotFound.svelte";

export const routes = new Map()
  .set("/", wrap({ asyncComponent: () => import("./Home.svelte") }))
  .set(
    "/todos",
    wrap({
      asyncComponent: () => import("./List.svelte"),
      loadingComponent: RouteLoading
    })
  )
  .set(
    "/todos/:id",
    wrap({
      asyncComponent: () => import("./Todo.svelte"),
      loadingComponent: RouteLoading
    })
  )
  .set(
    "/todos/:id/edit",
    wrap({
      asyncComponent: () => import("./Edit.svelte"),
      loadingComponent: RouteLoading
    })
  )
  .set(
    "/new",
    wrap({
      asyncComponent: () => import("./New.svelte"),
      loadingComponent: RouteLoading
    })
  )
  // ... and so on
  .set("*", RouteNotFound);

Can we avoiding repeating: loadingComponent: RouteLoading for each route?

In my projects the loader for the routes is always the same component.

@ItalyPaleAle
Copy link
Owner

This was actually by design. There was a conversation here and the feedback I got was that people wanted the ability to be able to specify different loading components for different routes. So this is what we have :) I know it's a bit repetitive, but it is the only way (without introducing defaults which I'm really not excited about, as then the API really grows complicated).

@ItalyPaleAle ItalyPaleAle added the wontfix This will not be worked on label Oct 4, 2020
@frederikhors
Copy link
Contributor Author

This link (https://github.com/ItalyPaleAle/svelte-spa-router/issues/739) is wrong in your answer.

@ItalyPaleAle
Copy link
Owner

Sorry, made a typo. Should have been: #73

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants