clj-commons / secretary

A client-side router for ClojureScript.
773 stars 64 forks source link

Check if a route exists v2.0.0 #77

Open bago2k4 opened 8 years ago

bago2k4 commented 8 years ago

Hi, what is the best way to check if a route is handled in version 2? In the previous version there was a function called locate-route that was very helpful. Thanks

bago2k4 commented 8 years ago

Hello again, any news on this? I see that this would be helpful also for this issue because with a response i'll be able to update accountant to Secretary 2 as for this issue. Thanks again

noprompt commented 8 years ago

@bago2k4 Sorry for the delay on getting back to you. locate-route isn't necessary on the 2.0.0 branch because the creation of routes and how to dispatch to them is pretty much up to the programmer. If you were to put routes in a vector or list locate-route is pretty much

(defn locate-route [routes-haystack needle]
  (some
   (fn [route]
     (when (route-matches route needle)
       route))
   routes-haystack))