Giter VIP home page Giter VIP logo

Comments (10)

intermundos avatar intermundos commented on September 18, 2024 1

Sure, I will try ๐Ÿ‘

from yrv.

pateketrueke avatar pateketrueke commented on September 18, 2024

Oh, nice question, I haven't look at it yet... I need some time to explore this, thank you!

from yrv.

pateketrueke avatar pateketrueke commented on September 18, 2024

Hi, now you can use the dynamic and pending attributes for that, e.g.

<Route dynamic={import('./your/component.js')} pending="Loading ..." />

from yrv.

jhechtf avatar jhechtf commented on September 18, 2024

from yrv.

intermundos avatar intermundos commented on September 18, 2024

Hello folks,

@pateketrueke thanks for sleek router.

I've been playing with it lately, but couldn't manage it to work dynamically. I did as specified above, but the component I try to load dynamically appears in the browser straight on load.

   <Route path="/World" dynamic={ import(/* webpackChunkName: "async" */'@/components/async.svelte') } pending="Loading..."/>

On network it appears straight away.

image

Any help is appreciated.

from yrv.

pateketrueke avatar pateketrueke commented on September 18, 2024

but the component I try to load dynamically appears in the browser straight on load.

So the component is rendered regardless the current/active route? Or you say the network request should not be needed until actual usage?

Probably we need a special way to lazily inline the promise wheen needed (if the later), e.g.

<Route dynamic={() => import(...)} />

I think we can detect if its value is a function or a promise... based on that we can then delay the actual loading of the underlying component.

What do you think?

from yrv.

intermundos avatar intermundos commented on September 18, 2024

Thanks for swift reply!

I think this kind of functionality would be great. Tough may cause some misunderstanding of what exactly does dynamic prop.

May be it would be better to have "dynamic" prop only for async loading of components on demand, while "component" prop may have this functionality of getting either svelte component or import statement.

from yrv.

pateketrueke avatar pateketrueke commented on September 18, 2024

May be it would be better to have "dynamic" prop only for async loading of components on demand, while "component" prop may have this functionality of getting either svelte component or import statement.

I like that, would you mind on opening a PR with those changes?

from yrv.

intermundos avatar intermundos commented on September 18, 2024

Submitted PR:
Dynamic components

from yrv.

intermundos avatar intermundos commented on September 18, 2024

Resolved in Dynamic components.

from yrv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.