From 0c2ac8352cf94d8b0069d36408d073b014e77ce0 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sat, 9 Jul 2016 15:05:06 +0300 Subject: [PATCH] Minor improvements on router ns. --- src/uxbox/util/router.cljs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/uxbox/util/router.cljs b/src/uxbox/util/router.cljs index 7f976d123..3a36dff80 100644 --- a/src/uxbox/util/router.cljs +++ b/src/uxbox/util/router.cljs @@ -55,17 +55,20 @@ ;; --- Public Api (defn init - [routes] - (let [opts {:on-navigate #(rs/emit! (update-location %)) - :default-location {:handler :auth/login}} - router (bidi.router/start-router! routes opts)] - (set! +routes+ routes) - (set! +router+ router))) + ([routes] + (init routes nil)) + ([routes {:keys [default] :or {default :auth/login}}] + (let [opts {:on-navigate #(rs/emit! (update-location %)) + :default-location {:handler default}} + router (bidi.router/start-router! routes opts)] + (set! +routes+ routes) + (set! +router+ router)))) (defn go "Redirect the user to other url." ([id] (go id nil)) - ([id params] (rs/emit! (navigate id params)))) + ([id params] + (rs/emit! (navigate id params)))) (defn route-for "Given a location handler and optional parameter map, return the URI