RiotGear / rg-router

State based router for Riot apps
MIT License
28 stars 3 forks source link

asynchronous load #3

Open goldalworming opened 9 years ago

goldalworming commented 9 years ago

does it support asynchronous load .tag file?

so it can be declared in router but not loaded yet, if url go to tags it load the tag then display the page, I usually use oclazyload in angular, if rg-router can have same feature it will be very good

gregorypratt commented 9 years ago

So are you expecting the HTML tag to be appended to a rg-view tag of sorts?

Usage example:

<rg-view></rg-view>
rg.router.add({
  name: 'about',
  url: '/about',
  tags: ['/tags/common/sidebar.tag', '/tags/views/about.tag', '/tags/common/footer.tag'],
  history: false,
  resolve: () => new Promise(function (resolve, reject) {
    window.setTimeout(resolve, 2000)
  })
})
goldalworming commented 9 years ago

what is window.setTimeout(resolve, 2000) used for? does resolve executed after 2 seconds? what if the js file not loaded after 2 seconds? or file loaded before 2 seconds?

does router still waited until 2 seconds?

gregorypratt commented 9 years ago

Just an example promise you can tell the router to the wait for before going to the state.

The above is sample code to add a state rather than the inner workings of the router itself.

gregorypratt commented 9 years ago

It's also an example of how it could work with a few adjustments to help you with your feature request 👍

rodmar35 commented 7 years ago

Hi gregorypratt & goldalworming.

Please, could you give me an example for append content in tag from a other one ? Not only the promise.

Thanks in advance Rodmar