This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-05
Channels
- # admin-announcements (1)
- # beginners (17)
- # boot (5)
- # cljs-dev (50)
- # cljsrn (20)
- # clojars (8)
- # clojure (108)
- # clojure-belgium (1)
- # clojure-brasil (1)
- # clojure-greece (6)
- # clojure-japan (1)
- # clojure-russia (12)
- # clojure-spec (77)
- # clojurescript (19)
- # core-async (2)
- # cursive (4)
- # datomic (12)
- # dirac (6)
- # funcool (3)
- # hoplon (39)
- # lein-figwheel (14)
- # om (12)
- # onyx (3)
- # other-languages (1)
- # protorepl (14)
- # pure-frame (2)
- # re-frame (39)
- # reagent (1)
- # spirituality-ethics (3)
- # yada (7)
Pointers to why invoking the following handler causes the ratom to emit null?
(register-handler
:load-data
(fn [db _]
(js/console.warn "Loading data..")
(-> (js/fetch "")
(.then #(.json %))
(.then (fn [data] (mapv #(.-url %) data)))
(.then #(dispatch [:process-data %])))))
(register-handler
:load-data
(fn [db _]
(js/console.warn "Loading data..")
(-> (js/fetch "")
(.then #(.json %))
(.then (fn [data] (mapv #(.-url %) data)))
(.then #(dispatch [:process-data %])))
db))
Because I don't see
;; initial state of app-db
(def app-db {:greeting "Hello Clojure in iOS and Android!" :data (mapv str (range 1 100))})
getting registered anywhereif you want to reset the db to the default values, you can dispatch :initialize-db
anytime
nothing related to :initialize-db
. it’s just the first event processed, and its handler always return the default db
take a look in init
inside core.cljs
. there should be a line like this: (dispatch-sync [:initialize-db])
Certainly, I really appreciate the response, I hope this is documented and that I missed to read the section
idk if it’s documented as it’s more of a pattern present in the template, rather than some re-frame characteristic
@debug, When you dispatch with a key, that adds your dispatch-vector the event-queue, which uses the first item in the dispatch-vector (`:initialize-db`) to lookup what handler function to use.
Next the handler function for your dispatch vector is used to swap the current value of the db
@debug: look what i found in re-frame’s wiki: https://github.com/Day8/re-frame/wiki/Bootstrap-An-Application#the-right-data
There’s gold in that wiki