Last active
August 29, 2015 14:20
-
-
Save ddellacosta/5cb1ea73fbe67dce1acf to your computer and use it in GitHub Desktop.
No idea if this actually works, but should be something like this
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 some-namespace | |
(:require | |
[om.core :as om] | |
[om.dom :as dom])) | |
(defn time-widget | |
[{:keys [msg-time] :as msg} owner] | |
(reify | |
om/IRenderState | |
(render-state [_ _] | |
(dom/time #js {:dateTime (.fromNow (js/moment msg-time))})))) | |
(defn messages ; or whatever your parent component is | |
[msgs owner] | |
(reify | |
om/IWillMount | |
(will-mount [_] | |
(.setInterval js/window | |
#(om/set-state! owner :update (.format (js/moment))) ; just in here as a dummy value that changes | |
, 1000)) | |
om/IRenderState | |
(render-state [_ {:keys [update]}] | |
(om/build-all msgs time-widget {:state {:update update}})))) |
Author
ddellacosta
commented
Apr 29, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment