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

Route Mapping #1

Closed
duckbox opened this issue Feb 10, 2014 · 4 comments
Closed

Route Mapping #1

duckbox opened this issue Feb 10, 2014 · 4 comments

Comments

@duckbox
Copy link

duckbox commented Feb 10, 2014

moved from Vue roadmap

In terms of the vue-router. Are we mapping routes to something acting like a 'PageController' ( some Vue type/instance ) that would hold configurable child instances? Or is this like a state event to be emitted amongst all instances?

I don't know. I'm having trouble visualizing what is dictated as a 'page' or something centric to represent a container. How do you guys see this fleshing out?

@duckbox
Copy link
Author

duckbox commented Feb 11, 2014

Based on IRC discussions, vue-router will require a selector, acting as the stage for routeViews, routes and components.

Potentially looking like,

Vue.router('#container',{
   '' : 'users',
   'user/:id' : 'user',
   'user/:id/edit' : 'edit-user'
});

Separate question regarding plugins, if something is not a Vue service ( directive, filter etc ). What is an acceptable way to expose this?

exports.install = function( Vue ) {
    Vue.router = function( ops ){/*test*/};
}

@yyx990803
Copy link
Member

I think install should be used only for registering global Vue assets.

Imagine a plugin that holds a bunch of utility directives. These directives should all be exposed in some way, together with the install method which registers all of them globally via Vue.directive(). This way the user can either use Vue.use(plugin) to globally register everything, or cherry pick single directives from the plugin if needed.

For the case of router - I haven't made up my mind yet. I'll probably start on it this weekend and we'll see what feels right.

@duckbox
Copy link
Author

duckbox commented Feb 12, 2014

No, I totally get you. Its how I approached mocking vue-import. Was just making sure as I'd imagine Router would not be a directive. Perfectly doable as you know, but feels wrong.

@ayamflow
Copy link

ayamflow commented Mar 4, 2014

I'm wondering about that too, I'm building a vue-router for my own purpose (& for learning) and was curious about which API would be the best. Currently I do:

app.config({
    defaultRoute: 'home',
    rootElement: '#view',
    baseRoute: '/example'
});
app.route('/home', 'home-page'); // path, component
app.route('/about', 'about-page');

app.start();

I like @duckbox proposal though.

I'm sticking on an angular-like API for now, so each update of the route dispatch $locationChanged/$routeChangeSuccess events and maintain a global $location-like object (which is basically a wrapped page.js context). Then I directly update the visible component according to the route. I was wondering if a v-route directive would be nice, in the spirit of angular ngView.

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

3 participants