application icon indicating copy to clipboard operation
application copied to clipboard

Router: Have a routes collection interface & support in Tracy router panel

Open Andrewsville opened this issue 9 years ago • 4 comments

  • Feature
  • Documentation – No change needed, unless you want to mention it in the "Custom Router" chapter.
  • BC break - no

Currently, the only way to have a collection of routes and have them displayed in the Tracy panel is to use the RouteList class.

This PR generalizes this logic to allow developers to implement their own route collections maybe with some logic inside (the RouteList is just a simple hashmap), maybe immutable (RouteList is mutable), etc. It comes from our use case but I believe it could be useful for others, too.

  • This PR introduces a new interface for route lists that extends IteratorAggregate (which is the easiest way to implement a Traversable) and adds the getModule() method that is required by the Tracy panel.
  • Because of the way RouteList is implemented, it can implement this new interface without any changes.
  • And the last change is the instanceof typecheck in the Panel to display a routes collection.

Andrewsville avatar Sep 30 '15 08:09 Andrewsville

Personally, I like this idea. :) :+1:

pavelkouril avatar Sep 30 '15 09:09 pavelkouril

I dislike the getModule() method onIRouteList.

JanTvrdik avatar Sep 30 '15 09:09 JanTvrdik

Well, it is required by the Panel. There's not much I can do about it. You could say the same about the RouteList itself where its sole purpose is to be printed by the panel.

Andrewsville avatar Sep 30 '15 10:09 Andrewsville

I like it. Could we merge it, rebase it or close it?

f3l1x avatar Jun 21 '17 20:06 f3l1x