riot-route-tag: tag based router for Riot.js
See original GitHub issueI’m thinking about tag-based router as a new feature. I’m now working on feature/route-tag branch and I’d like to share my current idea here. Nothing was decided yet. Any feedback is welcome!
Todos
- for the first release
- implement
riot-route-tag
(draft) - write tests
-
2 packages in 1 repo2 builds in 1 repo - adjust api specs (gathering ideas)
- write documents
- implement
- for the second release
- fix some logic on
riot-route
- maybe a little fix on
riot
, too
- fix some logic on
Specs (proposal)
<app>
<router>
<route path="fruit/apple"><p>Apple</p></route>
<route path="fruit/banana"><p>Banana</p></route>
<route path="fruit/*"><inner-tag /></route>
</router>
</app>
<inner-tag>
<p>{ name } is not found</p>
<script>
this.on('route', name => this.name = name)
</script>
</inner-tag>
<router>
- it can contains multiple routes
it hasmaybe laterbase
attribute (optional)- equivalent to
const r = route.create()
so it creates subrouter
<route>
- it has
path
attribute <route path="fruit/apple">
is equivalent tor('fruit/apple', () => { ... })
- when the route has selected, it triggers route event on its children and passes some arguments to them
- it has
Two builds:
- route.js: almost same as v3.0
- route+tag.js: includes tags above and it includes
riot-route
inside
We could import them like this:
import route from 'riot-route'
// or
import route from 'riot-route/lib/tag' // note that it's not same as cjs below
const route = require('riot-route')
// or
const route = require('riot-route/tag')
Q&A
Q: What ispackages
dir?A: to provide 2 packages in one repo
- Q: Why not making a separated repo?
- A: riot-route-tag is tightly coupled with riot-route
Q: Why two npm packages?A: because of ES6 and CJS modules handling. We have no general way to provide submodules in both at this point:require('riot-route/tag')
is not compatible withimport 'riot-route/tag'
.
- Q: Why now?
- A: Riot v3 has got much better
if
implementation 😄
- A: Riot v3 has got much better
Related informations:
- html-router in ikki: my experiment on Riot.js last year
- react-router: declarative routing for React
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:17 (16 by maintainers)
Top Results From Across the Web
Router · Riot.js
Tag -based routing. >= v3.1. This feature allows you to write your routes as declarative tags: <app> ...
Read more >Riot.JS Unable to handle subRoute while using Tag-based ...
In my app-user.tag I'm only able to extract first level of detail but not the entire sub-route into tokens. Here is the plunkr...
Read more >riot/route: Simple isomorphic router - GitHub
The Riot.js Router is the minimal router implementation with such technologies: compatible with the DOM pushState and history API; isomorphic functional API ...
Read more >The router I always wished for in riot jS | by Prateek Bhatnagar
Introducing riot-tagrouter · Router tag, this gather the routes and creates tags on respective callbacks with appropriate data. · Route tag which ...
Read more >Documentation - RiotJS
This command will let you pick your favourite bundler and will create in the current folder all the files necessary to start coding...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
OK, v3.1.0 has been released just now with our new tag based router 🎉
@karantir sounds interesting. How about simply making seperated
<lazy>
loading tag?I think we don’t have to couple the router and lazy loader, at this point.