question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

riot-route-tag: tag based router for Riot.js

See original GitHub issue

I’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 repo 2 builds in 1 repo
    • adjust api specs (gathering ideas)
    • write documents
  • for the second release
    • fix some logic on riot-route
    • maybe a little fix on riot, too

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 has base attribute (optional) maybe later
    • equivalent to const r = route.create() so it creates subrouter
  • <route>
    • it has path attribute
    • <route path="fruit/apple"> is equivalent to r('fruit/apple', () => { ... })
    • when the route has selected, it triggers route event on its children and passes some arguments to them

Two builds:

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 is packages 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 with import 'riot-route/tag'.
  • Q: Why now?
    • A: Riot v3 has got much better if implementation 😄

Related informations:

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
cognitomcommented, Jan 29, 2017

OK, v3.1.0 has been released just now with our new tag based router 🎉

1reaction
cognitomcommented, Feb 23, 2017

@karantir sounds interesting. How about simply making seperated <lazy> loading tag?

<app>
  <router>
    <route path="fruit/*"><inner-tag /></route>
    <route path="veggie/*"><lazy src="tags/lazy-inner-tag.tag" /></route>
  </router>
</app>

I think we don’t have to couple the router and lazy loader, at this point.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found