Skip to content

Instantly share code, notes, and snippets.

@yogthos
Created October 19, 2018 22:11
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 yogthos/9a306dc9d3f8e51a0bcbda55fce99d43 to your computer and use it in GitHub Desktop.
Save yogthos/9a306dc9d3f8e51a0bcbda55fce99d43 to your computer and use it in GitHub Desktop.
example of adapting Reagent atom based API to re-frame
(ns re-frame.datepicker
(:require [cljs-pikaday.reagent :as pikaday]))
(defn datepicker [k]
(r/with-let [date (r/atom @(rf/subscribe [:schedule/event-modal-details-value k]))
date-tracker (r/track! #(rf/dispatch [:schedule/update-event-modal-details k @date]))]
[pikaday/date-selector
{:date-atom date
:pikaday-attrs {:format "YYYY-MM-DD"}
:input-attrs {:read-only true :class "form-control"}}]
(finally (r/dispose! date-tracker))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment