Skip to content

Instantly share code, notes, and snippets.

@akond
Created February 13, 2017 15:21
Show Gist options
  • Select an option

  • Save akond/3ffa6dce6fa97aeb83562a64d6ce8349 to your computer and use it in GitHub Desktop.

Select an option

Save akond/3ffa6dce6fa97aeb83562a64d6ce8349 to your computer and use it in GitHub Desktop.
(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"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment