2018-08-09 11:28:37 +02:00
|
|
|
(ns sliva.routes
|
|
|
|
(:import goog.history.Html5History)
|
|
|
|
(:require [secretary.core :as secretary :refer-macros [defroute]]
|
|
|
|
[goog.events :as events]
|
|
|
|
[goog.history.EventType :as EventType]
|
|
|
|
[sliva.data :refer [appstate]]))
|
|
|
|
|
|
|
|
(defn hook-browser-navigation! []
|
|
|
|
(doto (Html5History.)
|
|
|
|
(events/listen
|
|
|
|
EventType/NAVIGATE
|
|
|
|
(fn [event]
|
|
|
|
(secretary/dispatch! (.-token event))))
|
|
|
|
(.setEnabled true)))
|
|
|
|
|
|
|
|
(defn app-routes []
|
2018-08-10 16:35:52 +02:00
|
|
|
;;(secretary/set-config! :prefix "#☭")
|
|
|
|
(secretary/set-config! :prefix "#")
|
|
|
|
(defroute "/" [] (swap! appstate assoc :page :hub))
|
|
|
|
(defroute "/hub" [] (swap! appstate assoc :page :hub))
|
|
|
|
(defroute "/visual" [] (swap! appstate assoc :page :visual))
|
|
|
|
(defroute "/test" [] (console.log "test!"))
|
2018-08-10 18:29:18 +02:00
|
|
|
(defroute "/gibanica" [] (swap! appstate assoc :page :gibanica))
|
2018-08-09 11:28:37 +02:00
|
|
|
(hook-browser-navigation!))
|