petterik / lajter

MIT License
3 stars 0 forks source link

Add routing #12

Closed petterik closed 6 years ago

petterik commented 6 years ago

Routing works by having components declare :lajter/routing in the component:

  {:lajter/id      :lajter.web.main/Router
   :lajter/routing {:navbar {:route.navbar/a NavbarA
                             :route.navbar/b NavbarB}
                    :body   {:route.body/a ComponentA
                             :route.body/b ComponentB}}
  ...
   }

The component can then call render-route like so:

(dom/div nil
  (la/render-route this :navbar)
  (la/render-route this :body))

Which renders the component for the given route.

The route is selected by a :route-fn that's passed to the reconciler.