Skip to content

Instantly share code, notes, and snippets.

@tangrammer
Created February 6, 2014 08:32
Show Gist options
  • Save tangrammer/8840332 to your computer and use it in GitHub Desktop.
Save tangrammer/8840332 to your computer and use it in GitHub Desktop.
(ns heroku.index
(:require-macros [cljs.core.async.macros :refer [go]])
(:require
[heroku.util :as util]
[ajax.core :refer [GET POST]]
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[clojure.browser.repl]
[cljs.core.async :refer [put! chan <!]])
)
(enable-console-print!)
(def app-state (atom {:title "Shared example" :nav "the nav"}))
(def c (chan))
(om/root
app-state
{:some-text "I'm shared!" :c c}
(fn [app owner]
(reify
om/IWillMount
(will-mount [_]
(comment go (loop []
(let [interaction (<! (om/get-shared owner :c))]
(comment om/transact! app :contacts
(fn [xs] (vec (remove #(= contact %) xs))))
(println interaction )
(recur)))))
om/IRender
(render [_]
(dom/div nil
(dom/h1 #js{:onClick (fn [e] (put! (om/get-shared owner :c) "hola updated"))} (:title app))
(dom/p nil
(om/get-shared owner :some-text))))))
(.getElementById js/document "my-app"))
(om/root
app-state
{:some-text "I'm nav shared!" :c c}
(fn [app owner]
(reify
om/IWillMount
(will-mount [_]
(go (loop []
(let [interaction (<! (om/get-shared owner :c))]
(comment om/transact! app :contacts
(fn [xs] (vec (remove #(= contact %) xs))))
(println "from shared nav" interaction )
(recur)))))
om/IRender
(render [_]
(dom/div nil
(dom/h1 nil (:nav app))
(dom/p nil
(om/get-shared owner :some-text))))))
(.getElementById js/document "my-nav"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment