Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ulysses-front/src/cljs/ulysses/core.cljs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
39 lines (34 sloc)
1.1 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ulysses.core | |
(:require [reagent.core :as reagent] | |
[re-frame.core :as re-frame :refer [dispatch dispatch-sync]] | |
[ulysses.handlers] | |
[ulysses.subs] | |
[ulysses.routes :as routes] | |
[ulysses.views :as views] | |
[ulysses.config :as config] | |
[ulysses.lib.analytics :as analytics])) | |
(when config/debug? | |
(println "dev mode")) | |
(defn mount-root [] | |
(reagent/render [views/main-app] | |
(.getElementById js/document "app"))) | |
(defn hook-into-browser-events [] | |
(.addEventListener js/window "resize" | |
(fn [] (dispatch [:window-resize]))) | |
(.addEventListener js/window "scroll" | |
(fn [] (dispatch [:window-scroll])))) | |
(defn start-pollings [] | |
(let [pollings [[100 [:window-resize]] | |
[(* 30 1000) [:request-user-poll]]]] | |
(doseq [[time dval] pollings] | |
(dispatch-sync dval) | |
(js/setInterval | |
(fn [] (dispatch dval)) | |
time)))) | |
(defn ^:export init [] | |
(analytics/start) | |
(routes/app-routes) | |
(dispatch-sync [:initialize-db]) | |
(mount-root) | |
(hook-into-browser-events) | |
(start-pollings)) |