Skip to content

Instantly share code, notes, and snippets.

@Andre0991
Created April 2, 2021 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andre0991/957fb60589a6085136cc0a53efa51ca1 to your computer and use it in GitHub Desktop.
Save Andre0991/957fb60589a6085136cc0a53efa51ca1 to your computer and use it in GitHub Desktop.
timeline.cljs
(defn- timeline-panel
[]
(fn []
(re/create-class
{:component-did-mount (fn [comp]
(r/dispatch [:timeline/init (r-dom/dom-node comp) {}]))
:reagent-render (fn [_] [:div])})))
(r/reg-event-fx
:timeline/init
(fn [{:keys [db]} [_ node opts]]
(let [items-dataset (new vis-data/DataSet (clj->js []))
groups-dataset (new vis-data/DataSet (clj->js []))
el (new vis/Timeline
node
items-dataset
groups-dataset
(clj->js opts))]
{:db (-> db
(assoc-in [:timeline :datasets :items] items-dataset)
(assoc-in [:timeline :datasets :groups] groups-dataset)
(assoc-in [:timeline :el] el)
;; version is updated whenever some dataset is changed
;; in this way, datasets subscriptions will get notified
(assoc-in [:timeline :version] 0))})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment