Created
February 13, 2017 15:21
-
-
Save akond/3ffa6dce6fa97aeb83562a64d6ce8349 to your computer and use it in GitHub Desktop.
Revisions
-
akond created this gist
Feb 13, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ (ns component.core (:require [reagent.core :as r] [com.stuartsierra.component :as component])) (enable-console-print!) (defrecord Database [host port] component/Lifecycle (start [component] component) (stop [component] component)) (defn getdb [scheduler] (.log js/console (get scheduler :db)) scheduler) (defrecord Scheduler [db] component/Lifecycle (start [component] component) (stop [component] component) ) (defn example-system [config-options] (let [{:keys [host port]} config-options] (component/system-map :db (map->Database {:host host :port port}) :scheduler (component/using (map->Scheduler {}) [:db]) ))) (def a (component/start (example-system {:host "localhost" :port 3606}))) (.log js/console "START") (.log js/console (getdb (:scheduler a))) (defn application [] [:div "Haha"]) (r/render [application] (.getElementById js/document "app"))