Created
April 2, 2021 22:26
-
-
Save Andre0991/957fb60589a6085136cc0a53efa51ca1 to your computer and use it in GitHub Desktop.
timeline.cljs
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
(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