Skip to content

Instantly share code, notes, and snippets.

@Deraen
Created August 18, 2016 10:58
Show Gist options
  • Save Deraen/40ed55e8e257394a1a32c7613326fa7b to your computer and use it in GitHub Desktop.
Save Deraen/40ed55e8e257394a1a32c7613326fa7b to your computer and use it in GitHub Desktop.
Kekkonen + Re-frame
(reg-event-fx :get-current-party
(fn [{:keys [db]} _]
{:db (assoc db :loading? true)
:kekkonen {:query :api.party/get-current-party
;; called with the body
:on-success [:set-current-party]
;; or simple assoc-in?
:on-success [:assoc-in [:current-party]]
}}))
(reg-event :set-current-party
(fn [db [_ current-party]]
(assoc db :current-party current-party)))
(reg-event :assoc-in
(fn [db [_ ks v]]
(assoc-in db ks v)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment