From a5d23b5e0d49544afc62a5085227f4f77049a269 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 27 Jan 2020 17:51:35 +0100 Subject: [PATCH 01/11] Dynamic Routing --- active-rfcs/0000-router-dynamic-routing.md | 164 +++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 active-rfcs/0000-router-dynamic-routing.md diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0000-router-dynamic-routing.md new file mode 100644 index 00000000..d32ba5b2 --- /dev/null +++ b/active-rfcs/0000-router-dynamic-routing.md @@ -0,0 +1,164 @@ +- Start Date: 2020-01-27 +- Target Major Version: Vue 3 Router 4 +- Reference Issues: [issues](https://github.com/vuejs/vue-router/issues?q=is%3Aopen+is%3Aissue+label%3A%22group%5Bdynamic+routing%5D%22) +- Implementation PR: + +# Summary + +Introducing an API that allows adding and removing route records while the router is working + +- `router.addRoute(route: RouteRecord)` +- `router.removeRoute(name: string)` +- `router.getRoutes()` + +# Basic example + +Given a router instance in a running app: + +```ts +router.addRoute({ + path: '/new-route', + name: 'NewRoute', + component: NewRoute +}) + +// add to the children of an existing route +router.addRoute('ParentRoute', { + path: 'new-route', + name: 'NewRoute', + component: NewRoute +}) + +router.removeRoute('NewRoute') + +// normalized version of the records added +const routeRecords = router.getRoutes() +``` + +# Motivation + +Dynamic routing is a feature that enables applications to build its own routing system. An usecase of this is the vue-cli ui, that allows adding graphical plugins which can have their own interfaces. + +The current version of Vue Router only supports adding a new absolute route. The idea of this RFC is to add the missing functions to allow dynamic routing. Thinking about the different ways this API can be shaped and what is best for the future of Vue Router. Currently, it's impossible to achieve the example described above without hacks or creating a whole new Router instance. + +In theory this could also improve Developer experience by changing routes in place with Hot Module Replacement. + +Note: Dynamic routing only makes sense after implementing path ranking (automatic route order that allows route records to be add in any order but still be matched correctly). Most of the cost of adding this feature is on the path scoring side. + +# Detailed design + +## `addRoute` + +- Allow adding an absolute route +- Allow adding a child route +- How should conflicts be handled? +- What should be returned by the function? + +The code samples are written in TS to provide more information about what is the shape of the object expected: + +`RouteRecord` is the same kind of object used in the `routes` option when instantiating the Router. To give you an idea, it looks like (https://router.vuejs.org/api/#routes) but what matters is that this object is consistent with the `routes` options since the `RouteRecord` type might have minor changes in the future version of Vue Router 4. + +```ts +const routeRecord: RouteRecord = { + path: '/new-route', + name: 'NewRoute', + component: NewRoute +} +``` + +There are different options of what to return from `addRoute` + +Returning a function that allows removing the route is useful for unamed routes + +```ts +const removeRoute = router.addRoute(routeRecord) + +removeRoute() // removes the route record +// or +router.removeRoute('NewRoute') // because names are unique +``` + +If we are on `/new-route`, adding the record will trigger a _replace_ navigation and will trigger all will trigger navigation guards. In this scenario `from` will be a route location with an empty `matched` array and missing all extra properties like `meta` and `name` while `to` will be the same actual location (same `path`, `fullPath`, `query` and `hash`) but with a non-empty array of `matched`. + +_For Alternatives, please check [alternatives](#alternatives)_ + +### Conflicts + +When adding a route that has the same name as an existing route, it should replace the existing route and warn about it (in dev only). This is the most convenient version because it allows replacing new routes without removing the old ones **when they are using the same name**. + +Alternatives: + +- Fail and throw an error that asks the user to replace it first: less convenient +- Not warn the user but still replace it: could be prone to difficult to debug errors + +### Nested routes + +Depending on what is returned by `addRoute`, a nested route can be added by referencing the name of an existing route. This forces parent routes to be named. + +```ts +router.addRoute('ParentRoute', routeRecord) +``` + +### Signature + +```ts +interface addRoute { + (parentName: string, route: RouteRecord): () => void + (route: RouteRecord): () => void +} +``` + +## `removeRoute` + +Removing a route removes all its children as well. If we were on the removed route, the router should re route, which could end up in the catch-all route (`path: '*'`). + +```ts +interface removeRoute { + (name: string): () => void +} +``` + +# Drawbacks + +- This API increases vue-router size. To make it treeshakable will require allowing the matcher (responsible for parsing `path` and doing the path ranking) to be extended with simpler versions, which are quite complex to write. + Why should we _not_ do this? Please consider: + +- implementation cost, both in term of code size and complexity +- whether the proposed feature can be implemented in user space +- the impact on teaching people Vue +- integration of this feature with other existing and planned features +- cost of migrating existing Vue applications (is it a breaking change?) + +There are tradeoffs to choosing any path. Attempt to identify them here. + +# Alternatives + +## `addRoutes` + +- A promise that resolves or reject based on the possible navigation that adding the record might trigger (e.g. being on `/new-route` before adding the route) + +```ts +window.location.pathname // "/new-route" +// 1. The promise of a function that allows removing the route record +const removeRoute = await router.addRoute(routeRecord) +// 2. The same kind of promise returned by `router.push`. +const route = await router.addRoute(routeRecord) + +removeRoute() // removes the route record +// or +router.removeRoute('NewRoute') // names are unique +``` + +- We could also force the user to manually `push` after adding routes to avoid any promise based api on `addRoute` + +- A reference to the record added (a normalized copy of the original record) + +```ts +// js object (same reference hold by the router) +const normalizedRouteRecord = router.addRoute(routeRecord) +router.removeRoute(normalizedRouteRecord) +``` + +# Adoption strategy + +This API is backwards compatible with what exists in Vue Router 3 From 2bc0292c6222174a2777678c4e385b6e18c725e5 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 27 Jan 2020 17:53:07 +0100 Subject: [PATCH 02/11] precision from --- active-rfcs/0000-router-dynamic-routing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0000-router-dynamic-routing.md index d32ba5b2..37a8085a 100644 --- a/active-rfcs/0000-router-dynamic-routing.md +++ b/active-rfcs/0000-router-dynamic-routing.md @@ -78,7 +78,7 @@ removeRoute() // removes the route record router.removeRoute('NewRoute') // because names are unique ``` -If we are on `/new-route`, adding the record will trigger a _replace_ navigation and will trigger all will trigger navigation guards. In this scenario `from` will be a route location with an empty `matched` array and missing all extra properties like `meta` and `name` while `to` will be the same actual location (same `path`, `fullPath`, `query` and `hash`) but with a non-empty array of `matched`. +If we are on `/new-route`, adding the record will trigger a _replace_ navigation and will trigger all will trigger navigation guards. In this scenario, if no catch-route (path: '\*') is present, `from` will be a route location with an empty `matched` array and missing all extra properties like `meta` and `name` while `to` will be the same actual location (same `path`, `fullPath`, `query` and `hash`) but with a non-empty array of `matched`. _For Alternatives, please check [alternatives](#alternatives)_ From ceff0c38f1ab66e70f3c31a4b331dd3a70d6b808 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 27 Jan 2020 17:57:12 +0100 Subject: [PATCH 03/11] add getRoutes --- active-rfcs/0000-router-dynamic-routing.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0000-router-dynamic-routing.md index 37a8085a..8e3efd37 100644 --- a/active-rfcs/0000-router-dynamic-routing.md +++ b/active-rfcs/0000-router-dynamic-routing.md @@ -118,6 +118,18 @@ interface removeRoute { } ``` +## `getRoutes` + +Allows reading the list of normalized active route records: + +```ts +interface getRoutes { + (): RouteRecordNormalized[] +} +``` + +What is present in RouteRecordNormalized is yet to be precised but contains at least all existing properties from a RouteRecord, some of them normalized (like `components` instead of `component` and an `undefined` name) + # Drawbacks - This API increases vue-router size. To make it treeshakable will require allowing the matcher (responsible for parsing `path` and doing the path ranking) to be extended with simpler versions, which are quite complex to write. From f306c49b6d4a856cb8e76ce54b22236c17d8db96 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 27 Jan 2020 18:00:17 +0100 Subject: [PATCH 04/11] add alternative for getRoutes --- active-rfcs/0000-router-dynamic-routing.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0000-router-dynamic-routing.md index 8e3efd37..384766f9 100644 --- a/active-rfcs/0000-router-dynamic-routing.md +++ b/active-rfcs/0000-router-dynamic-routing.md @@ -171,6 +171,10 @@ const normalizedRouteRecord = router.addRoute(routeRecord) router.removeRoute(normalizedRouteRecord) ``` +## `getRoutes` + +There could also be a reactive property with the routes but this would allow using them in templates, which in most scenarios is an application level feature which could and should handle things the other way around **having a reactive source of route records that are syncronized with the router**. Doing this at the application level avoids adding the cost for every user + # Adoption strategy This API is backwards compatible with what exists in Vue Router 3 From 4f1fe8a7c25e04a756c1ecbf1409a6d22a82e342 Mon Sep 17 00:00:00 2001 From: pierresaid Date: Mon, 27 Jan 2020 21:59:01 +0100 Subject: [PATCH 05/11] fix: typo in 0000-router-dynamic-routing.md (#1) --- active-rfcs/0000-router-dynamic-routing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0000-router-dynamic-routing.md index 384766f9..a003f17e 100644 --- a/active-rfcs/0000-router-dynamic-routing.md +++ b/active-rfcs/0000-router-dynamic-routing.md @@ -78,7 +78,7 @@ removeRoute() // removes the route record router.removeRoute('NewRoute') // because names are unique ``` -If we are on `/new-route`, adding the record will trigger a _replace_ navigation and will trigger all will trigger navigation guards. In this scenario, if no catch-route (path: '\*') is present, `from` will be a route location with an empty `matched` array and missing all extra properties like `meta` and `name` while `to` will be the same actual location (same `path`, `fullPath`, `query` and `hash`) but with a non-empty array of `matched`. +If we are on `/new-route`, adding the record will trigger a _replace_ navigation and will trigger all navigation guards. In this scenario, if no catch-route (path: '\*') is present, `from` will be a route location with an empty `matched` array and missing all extra properties like `meta` and `name` while `to` will be the same actual location (same `path`, `fullPath`, `query` and `hash`) but with a non-empty array of `matched`. _For Alternatives, please check [alternatives](#alternatives)_ From 97de59d2fcf0bc27c5e18f92cf7b93e48b057941 Mon Sep 17 00:00:00 2001 From: atilkan Date: Wed, 29 Jan 2020 11:01:11 +0300 Subject: [PATCH 06/11] fix typo (#2) --- active-rfcs/0000-router-dynamic-routing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0000-router-dynamic-routing.md index a003f17e..361cec7a 100644 --- a/active-rfcs/0000-router-dynamic-routing.md +++ b/active-rfcs/0000-router-dynamic-routing.md @@ -37,7 +37,7 @@ const routeRecords = router.getRoutes() # Motivation -Dynamic routing is a feature that enables applications to build its own routing system. An usecase of this is the vue-cli ui, that allows adding graphical plugins which can have their own interfaces. +Dynamic routing is a feature that enables applications to build its own routing system. A usecase of this is the vue-cli ui, that allows adding graphical plugins which can have their own interfaces. The current version of Vue Router only supports adding a new absolute route. The idea of this RFC is to add the missing functions to allow dynamic routing. Thinking about the different ways this API can be shaped and what is best for the future of Vue Router. Currently, it's impossible to achieve the example described above without hacks or creating a whole new Router instance. From 8f403b680bd4a0d81b122078adb5ec15cc774426 Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 29 Jan 2020 10:10:28 +0100 Subject: [PATCH 07/11] Update 0000-router-dynamic-routing.md (#3) Just some grammatical corrections. Hope you don't mind. Scott --- active-rfcs/0000-router-dynamic-routing.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0000-router-dynamic-routing.md index 361cec7a..eb643224 100644 --- a/active-rfcs/0000-router-dynamic-routing.md +++ b/active-rfcs/0000-router-dynamic-routing.md @@ -43,7 +43,7 @@ The current version of Vue Router only supports adding a new absolute route. The In theory this could also improve Developer experience by changing routes in place with Hot Module Replacement. -Note: Dynamic routing only makes sense after implementing path ranking (automatic route order that allows route records to be add in any order but still be matched correctly). Most of the cost of adding this feature is on the path scoring side. +Note: Dynamic routing only makes sense after implementing path ranking (automatic route order that allows route records to be added in any order but still be matched correctly). Most of the cost of adding this feature is on the path scoring side. # Detailed design @@ -54,9 +54,9 @@ Note: Dynamic routing only makes sense after implementing path ranking (automati - How should conflicts be handled? - What should be returned by the function? -The code samples are written in TS to provide more information about what is the shape of the object expected: +The code samples are written in TS to provide more information about the shape of the object expected: -`RouteRecord` is the same kind of object used in the `routes` option when instantiating the Router. To give you an idea, it looks like (https://router.vuejs.org/api/#routes) but what matters is that this object is consistent with the `routes` options since the `RouteRecord` type might have minor changes in the future version of Vue Router 4. +`RouteRecord` is the same kind of object used in the `routes` option when instantiating the Router. To give you an idea, it looks like (https://router.vuejs.org/api/#routes). Important to note, this object is consistent with the `routes` options, since the `RouteRecord` type might have minor changes in the future version of Vue Router 4. ```ts const routeRecord: RouteRecord = { @@ -66,9 +66,9 @@ const routeRecord: RouteRecord = { } ``` -There are different options of what to return from `addRoute` +There are different options for what to return from `addRoute`. -Returning a function that allows removing the route is useful for unamed routes +Returning a function that allows removing the route is useful for unamed routes. ```ts const removeRoute = router.addRoute(routeRecord) @@ -78,13 +78,13 @@ removeRoute() // removes the route record router.removeRoute('NewRoute') // because names are unique ``` -If we are on `/new-route`, adding the record will trigger a _replace_ navigation and will trigger all navigation guards. In this scenario, if no catch-route (path: '\*') is present, `from` will be a route location with an empty `matched` array and missing all extra properties like `meta` and `name` while `to` will be the same actual location (same `path`, `fullPath`, `query` and `hash`) but with a non-empty array of `matched`. +If we are on `/new-route`, adding the record will trigger a _replace_ navigation and will trigger all navigation guards. In this scenario, if no catch-route (path: '\*') is present, `from` will be a route location with an empty `matched` array and missing all extra properties like `meta` and `name`, while `to` will be the same actual location (same `path`, `fullPath`, `query` and `hash`) but with a non-empty array of `matched`. _For Alternatives, please check [alternatives](#alternatives)_ ### Conflicts -When adding a route that has the same name as an existing route, it should replace the existing route and warn about it (in dev only). This is the most convenient version because it allows replacing new routes without removing the old ones **when they are using the same name**. +When adding a route that has the same name as an existing route, it should replace the existing route and warn about it (in dev only). This is the most convenient version, because it allows replacing new routes without removing the old ones **when they are using the same name**. Alternatives: @@ -128,7 +128,7 @@ interface getRoutes { } ``` -What is present in RouteRecordNormalized is yet to be precised but contains at least all existing properties from a RouteRecord, some of them normalized (like `components` instead of `component` and an `undefined` name) +What is present in RouteRecordNormalized is yet to be decided, but contains at least all existing properties from a RouteRecord, some of them normalized (like `components` instead of `component` and an `undefined` name). # Drawbacks @@ -147,7 +147,7 @@ There are tradeoffs to choosing any path. Attempt to identify them here. ## `addRoutes` -- A promise that resolves or reject based on the possible navigation that adding the record might trigger (e.g. being on `/new-route` before adding the route) +- A promise that resolves or rejects based on the possible navigation that adding the record might trigger (e.g. being on `/new-route` before adding the route) ```ts window.location.pathname // "/new-route" @@ -173,8 +173,8 @@ router.removeRoute(normalizedRouteRecord) ## `getRoutes` -There could also be a reactive property with the routes but this would allow using them in templates, which in most scenarios is an application level feature which could and should handle things the other way around **having a reactive source of route records that are syncronized with the router**. Doing this at the application level avoids adding the cost for every user +There could also be a reactive property with the routes, but this would allow using them in templates, which in most scenarios is an application level feature which could and should handle things the other way around, **having a reactive source of route records that are syncronized with the router**. Doing this at the application level avoids adding the cost for every user. # Adoption strategy -This API is backwards compatible with what exists in Vue Router 3 +This API is backwards compatible with the existing Vue Router 3. From 946e6441b6f049e39e0f12fee228cbc85716edb2 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sat, 22 Feb 2020 15:23:59 +0100 Subject: [PATCH 08/11] remove template drawbacks --- active-rfcs/0000-router-dynamic-routing.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0000-router-dynamic-routing.md index eb643224..ba1e0af2 100644 --- a/active-rfcs/0000-router-dynamic-routing.md +++ b/active-rfcs/0000-router-dynamic-routing.md @@ -132,16 +132,7 @@ What is present in RouteRecordNormalized is yet to be decided, but contains at l # Drawbacks -- This API increases vue-router size. To make it treeshakable will require allowing the matcher (responsible for parsing `path` and doing the path ranking) to be extended with simpler versions, which are quite complex to write. - Why should we _not_ do this? Please consider: - -- implementation cost, both in term of code size and complexity -- whether the proposed feature can be implemented in user space -- the impact on teaching people Vue -- integration of this feature with other existing and planned features -- cost of migrating existing Vue applications (is it a breaking change?) - -There are tradeoffs to choosing any path. Attempt to identify them here. +- This API increases vue-router size. To make it treeshakable will require allowing the matcher (responsible for parsing `path` and doing the path ranking) to be extended with simpler versions, which are quite complex to write but we could instead export different versions of the matcher and allow the user specifying the matcher in a leaner version of the router. # Alternatives @@ -177,4 +168,4 @@ There could also be a reactive property with the routes, but this would allow us # Adoption strategy -This API is backwards compatible with the existing Vue Router 3. +This API is backwards compatible with the existing Vue Router 3. From 1cbc78d9cc7522edf8286b5c4d05f0210c70eaab Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 26 Feb 2020 18:52:15 +0100 Subject: [PATCH 09/11] update --- active-rfcs/0000-router-dynamic-routing.md | 44 ++++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0000-router-dynamic-routing.md index ba1e0af2..ab375c65 100644 --- a/active-rfcs/0000-router-dynamic-routing.md +++ b/active-rfcs/0000-router-dynamic-routing.md @@ -7,9 +7,10 @@ Introducing an API that allows adding and removing route records while the router is working -- `router.addRoute(route: RouteRecord)` -- `router.removeRoute(name: string)` -- `router.getRoutes()` +- `router.addRoute(route: RouteRecord)` Add a new route +- `router.removeRoute(name: string | Symbol)` Remove an existing route +- `router.hasRoute(name: string | Symbol): boolean` Check if a route exists +- `router.getRoutes(): RouteRecord[]` Get the current list of routes # Basic example @@ -78,13 +79,24 @@ removeRoute() // removes the route record router.removeRoute('NewRoute') // because names are unique ``` -If we are on `/new-route`, adding the record will trigger a _replace_ navigation and will trigger all navigation guards. In this scenario, if no catch-route (path: '\*') is present, `from` will be a route location with an empty `matched` array and missing all extra properties like `meta` and `name`, while `to` will be the same actual location (same `path`, `fullPath`, `query` and `hash`) but with a non-empty array of `matched`. +If we are on `/new-route`, adding the record will **not** trigger a _replace_ navigation. The user is responsible for forcing a navigation by calling `router.push` or `router.replace` with the current location `router.replace(router.currentRoute.value.fullPath)`. Using the string version of the location ensures that a new location is resolved instead of the old one. If the route is added inside of a navigation guard, make sure to use the value from the `to` parameter: + +```js +router.beforeEach((to, from, next) => { + // ... + router.addRoute(newRoute) + next(to.fullPath) + // ... +}) +``` + +Because the Dynamic Routing API is an advanced API that most users won't directly use, having this split allows more flexible and optimized behavior. The recommended approach to add routes will still be the configuration based one. _For Alternatives, please check [alternatives](#alternatives)_ ### Conflicts -When adding a route that has the same name as an existing route, it should replace the existing route and warn about it (in dev only). This is the most convenient version, because it allows replacing new routes without removing the old ones **when they are using the same name**. +When adding a route that has the same name as an existing route, it should replace the existing route. This is the most convenient version, because it allows replacing new routes without having to explicitely remove the old ones **when they are using the same name**. Alternatives: @@ -103,24 +115,34 @@ router.addRoute('ParentRoute', routeRecord) ```ts interface addRoute { - (parentName: string, route: RouteRecord): () => void + (parentName: string | Symbol, route: RouteRecord): () => void (route: RouteRecord): () => void } ``` ## `removeRoute` -Removing a route removes all its children as well. If we were on the removed route, the router should re route, which could end up in the catch-all route (`path: '*'`). +Removing a route removes all its children as well. As with `addRoute`, it's necessary to trigger a new navigation in order to update the current displayed view by _RouterView_. ```ts interface removeRoute { - (name: string): () => void + (name: string | Symbol): () => void +} +``` + +## `hasRoute` + +Checks if a route exists: + +```ts +interface hasRoute { + (name: string | Symbol): boolean } ``` ## `getRoutes` -Allows reading the list of normalized active route records: +Allows reading the list of normalized route records: ```ts interface getRoutes { @@ -152,8 +174,6 @@ removeRoute() // removes the route record router.removeRoute('NewRoute') // names are unique ``` -- We could also force the user to manually `push` after adding routes to avoid any promise based api on `addRoute` - - A reference to the record added (a normalized copy of the original record) ```ts @@ -168,4 +188,4 @@ There could also be a reactive property with the routes, but this would allow us # Adoption strategy -This API is backwards compatible with the existing Vue Router 3. +- Deprecate `addRoutes` and add `addRoute` to Vue Router 3. Other methods are new. From 0e04ed1e4b740662f7600c2ff04c0178d01e8dbe Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Tue, 14 Apr 2020 13:42:45 +0200 Subject: [PATCH 10/11] rename Symbol to symbol, type typo --- active-rfcs/0000-router-dynamic-routing.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0000-router-dynamic-routing.md index ab375c65..7d2a0747 100644 --- a/active-rfcs/0000-router-dynamic-routing.md +++ b/active-rfcs/0000-router-dynamic-routing.md @@ -8,8 +8,8 @@ Introducing an API that allows adding and removing route records while the router is working - `router.addRoute(route: RouteRecord)` Add a new route -- `router.removeRoute(name: string | Symbol)` Remove an existing route -- `router.hasRoute(name: string | Symbol): boolean` Check if a route exists +- `router.removeRoute(name: string | symbol)` Remove an existing route +- `router.hasRoute(name: string | symbol): boolean` Check if a route exists - `router.getRoutes(): RouteRecord[]` Get the current list of routes # Basic example @@ -115,7 +115,7 @@ router.addRoute('ParentRoute', routeRecord) ```ts interface addRoute { - (parentName: string | Symbol, route: RouteRecord): () => void + (parentName: string | symbol, route: RouteRecord): () => void (route: RouteRecord): () => void } ``` @@ -126,7 +126,7 @@ Removing a route removes all its children as well. As with `addRoute`, it's nece ```ts interface removeRoute { - (name: string | Symbol): () => void + (name: string | symbol): void } ``` @@ -136,7 +136,7 @@ Checks if a route exists: ```ts interface hasRoute { - (name: string | Symbol): boolean + (name: string | symbol): boolean } ``` From d86b9d4a8f65612e8c97c85103d93cedd51c408a Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Tue, 14 Apr 2020 13:43:19 +0200 Subject: [PATCH 11/11] rename --- ...0-router-dynamic-routing.md => 0029-router-dynamic-routing.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename active-rfcs/{0000-router-dynamic-routing.md => 0029-router-dynamic-routing.md} (100%) diff --git a/active-rfcs/0000-router-dynamic-routing.md b/active-rfcs/0029-router-dynamic-routing.md similarity index 100% rename from active-rfcs/0000-router-dynamic-routing.md rename to active-rfcs/0029-router-dynamic-routing.md