Thanks a lot, Eduardo. That was extremely interesting. And I love the design of your slides. They're like super sexy.
Okay. So, let's check out the questions. But before everyone's first one, can you use type routes without file based routing?
So you can use the type routes without file based routing but the idea is you're splitting up the generation of the types and the writing of the routes so you have some manual work to do, whereas the whole point of having this approach is that the types are automatic and you don't need to worry about it, so you're less likely to make errors, it's less error prone.
Ok, definitely makes sense.
Ok, so let's check out what we have here, does this plugin support Vue 2?
Vue 2? No, no Vue 2 support because the types on the router are quite different so it would be a huge, it's mostly a time question, I just don't have enough time to make it support Vue 2 right now.
Ok, maybe in the future or? Or even, I doubt it to be able to find the time to do it in the future but I invite anybody to copy the code and fork it for Vrouter 2, definitely.
Ok, you've heard it, an open source opportunity.
Then, the next one, how should we handle protected routes with file-based routing?
So protected routes, usually you create a navigation guard, so you would still create your own navigation guard, the same way. You have the router instance somewhere, so you just router before each or before result. There are other patterns that you can use with Metafields, you can define Metafields on the routes, that allows you to have pretty fine navigation guards applied to multiple routes. So one single navigation guard that is applied in multiple pages.
OK, cool. I think it's a bit more difficult to explain without a code.
Cool, makes sense.
The next one is, any chance of the unplugging ViewRouter functionality making its way to Yes, we'll probably go, I mean, in order to do that we have to go through an RFC first. The difference is that it's not, I mean most of the code is not runtime, right? Most of the code is built in. So it still comes as something that will be kind of on the side, so if it becomes part of u-router it will still be like a vid plugin that is exposed through a different path like u-router slash plugin or something like that.
Okay, cool.
The next one is, can you define loaders in a separate file then import it into multiple components?
Yes, you just need to export the loader from the page to tell the router that this page is using that loader. That's it. And then you use the composable anywhere. So you need to first import the loader and then export that import?
Yeah, you can also just do export. I didn't say it but you have two scripts, you have the regular script and then the script set up. So in the regular script, that's where you can export things, and that's where you can just do export something from something else or you can import it and then export it because you will still need to import it on the setup if you don't import it in the other script. The editor makes it very easy to get the right behavior because it just autocompletes.
Okay, definitely makes sense.
Comments