Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Resolve prior to rendering handler #24

Closed
mmahalwy opened this issue May 16, 2015 · 1 comment
Closed

Resolve prior to rendering handler #24

mmahalwy opened this issue May 16, 2015 · 1 comment

Comments

@mmahalwy
Copy link

I was thinking about ui-router and it's powerful resolve feature. Curious if there is a good way to do it here.

index: {
        path: '/',
        method: 'get',
        page: 'index',
        title: 'Index.com',
        handler: require('../routes/Index')
    },

The only problem was that require('../routes/Index') is not the handler but something else (exports). Can handler take a function and return require('../routes/Index')?

For example, index would have statics:

statics: {
  resolve: {
    getUser() {
      return superagent.get('some_url').end().then((response) => {
        return response.user;
      })
    }
  }
}

Then in routes:

handler: () => {
  // Do something which i havent brainstormed yet but somehow injects to the handler...
    return require('../routes/Index')
}

I haven't figured out the best way yet though :(

@mridgway
Copy link
Collaborator

Right now it doesn't seem like this would be possible. I think if we added yahoo/fluxible#15, you would be able to have a store handle NAVIGATE_START and execute currentRoute.handler().getUser(). Otherwise we would need to bake the concept of handlers in to the navigateAction in a very prescriptive way.

@mmahalwy mmahalwy closed this as completed Jun 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants