Fork me on GitHub
Martin Mariano14:10:12

Hey guys! I am still a bit new into the Clojure(script) world. Perhaps someone can help me. I have some routes for frontend routing using reitit.frontend.easy, but I am failing to extract the route parameters for a controller. Here is some code:

(def router



     {:name ::main-view}]

     {:name ::game-view}


       {:name ::category-view}]


        {:name :subcategory-view
         :view mkv/variants-page
         {:parameters {:path [:game-id]}
          :start (fn [parameters]
                   (js/console.log "Entering subcategory view")
                   (info parameters)
                   (rf/dispatch [::rg/query
                                 {:subcategory "weapon_ak47"
                                  :lang        "en_us"}

        {:name :variant-view
         :view mkv/asset-page
         [{:start (fn [& params] (info "Entering variant view"))}
          :stop (fn [& params] (info "Exiting variant view"))]}]]]]

     {:name ::inventory-sell}]

     {:name ::advanced-filtering}]]))

(defn init-routes []
  (debug "initializing routes")
  (let [current-route (rf/subscribe [::current-route])]
    (rtfe/start! router
                 (fn [route history]
                   (info route)
                   (rfc/apply-controller (:controllers (:data route)) :start )
                   (rf/dispatch-sync [::set-current-route route]))
                 {:use-fragment false})

    (r/render [mkv/market-main current-route]
              (dom/getElement "market-container"))))
When the route matches on the /:subcategory-id and then "", the parameters are always nil when I print inside the route controller. I want to retrieve the :game-id parameter, from the previously ancestor ::game-view, and use it to retrieve some information. I tried searching for the docs but couldn't find an example like the nested structure like the one I am using.