Fork me on GitHub
#keechma
<
2016-03-07
>
mihaelkonjevic07:03:45

@roberto this defines the defaults for the route pattern. So, the first route definition matches either "foo" => {:page "foo"} or "" => {:page "home"}

roberto14:03:50

so, would just specifying “home” work?

:routes [“home” “:page/:slug” “:page/:slug/:action”]

mihaelkonjevic14:03:21

I think you could specify it like this :routes [["" {:page "home"}]]

mihaelkonjevic14:03:06

but I'm not sure, I'll have to write a test for that simple_smile

mihaelkonjevic14:03:48

basically the idea is that you have a pattern and when you pass in the data it will try to find the best route match based on the data + pattern defaults

mihaelkonjevic14:03:00

but in the place my order app

mihaelkonjevic14:03:19

it has 3 urls that are matched by that route (home, restaurants and order-history)

mihaelkonjevic14:03:27

so it makes sense to define the route like that

roberto14:03:51

when trying to locate a route, it does so sequentially?

mihaelkonjevic14:03:19

it will calculate the score for each route and then pick the best one https://github.com/keechma/keechma/blob/master/src/keechma/router.cljs#L91-L103

roberto14:03:36

oh, so it converts them to a set, cool. I was worried about having a long list of routes and the application slowing down because of that.

roberto14:03:54

but then again, that shouldn’t be happening (writing an app with hundreds of routes)

mihaelkonjevic14:03:57

yeah, I've used CanJS for years (and the router is ported from CanJS) and usually I would have way less than 10 route patterns

mihaelkonjevic14:03:17

you don't really need that much when you just translate data from one format to another

mihaelkonjevic14:03:28

+ I really like to use query params in some cases