Skip to content

Commit

Permalink
feat(router-lite): non-string support for fallback (#1730)
Browse files Browse the repository at this point in the history
* chore(router-lite): minor changes

* feat(router-lite): class as fallback

* refactor(router-lite): routable fallback

* docs(router-lite): routable fallback
  • Loading branch information
Sayan751 committed Apr 5, 2023
1 parent c8d912f commit 59da952
Show file tree
Hide file tree
Showing 11 changed files with 926 additions and 142 deletions.
9 changes: 6 additions & 3 deletions docs/user-docs/router-lite/configuring-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ You can also see this in action below.

{% embed url="https://stackblitz.com/edit/router-lite-fallback-using-function?ctl=1&embed=1&file=src/my-app.html" %}

You can also use non-string fallbacks.
For example, you can use a class as the value for `fallback`; such as `fallback: NotFound`.
Or, if you are using a function, you choose to return a class instead of returning a string.
These combinations are also supported by router-lite.

## Case sensitive routes

Expand Down Expand Up @@ -820,6 +824,7 @@ You can see this configuration in action below.
## Using classes as routes

Using router-lite it is also possible to use the routed view model classes directly as routes configuration.
While doing so, if no paths have been explicitly configured for the components, the custom element name and aliases can be used as routing instructions.
The following example demonstrates that the `C1` and `C2` classes are used directly as the child routes for the `Root`.

```typescript
Expand All @@ -836,14 +841,12 @@ class C2 { }
class Root { }
```

The example above implies that `router.load('c-1')` and `router.load('c-2')` will load the `C1` and `C2` respectively.
The example above implies that `router.load('c-1')`, or `router.load('c-a')` and `router.load('c-2')`, `router.load('c-two')` will load the `C1` and `C2` respectively.

{% hint style="info" %}
To know more about the router API refer [this section](./navigating.md#using-the-router-api).
{% endhint %}

Note that this extends also for alias; that is using `router.load('c-a')` and `router.load('c-two')` will load the `C1` and `C2` respectively.

## Distributed routing configurations

The examples discussed so far demonstrate the classic use-cases of route configurations where the parents define the child routes.
Expand Down

0 comments on commit 59da952

Please sign in to comment.