This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-26
Channels
- # admin-announcements (4)
- # beginners (3)
- # boot (78)
- # cider (13)
- # cljs-dev (29)
- # cljs-edn (8)
- # cljsjs (11)
- # cljsrn (15)
- # clojure (81)
- # clojure-beijing (2)
- # clojure-belgium (3)
- # clojure-canada (1)
- # clojure-dusseldorf (8)
- # clojure-greece (6)
- # clojure-russia (40)
- # clojure-sg (1)
- # clojure-uk (59)
- # clojurebridge (1)
- # clojurescript (101)
- # core-logic (1)
- # cursive (3)
- # data-science (1)
- # datomic (60)
- # emacs (4)
- # error-message-catalog (12)
- # funcool (1)
- # hoplon (60)
- # jobs (1)
- # jobs-discuss (40)
- # leiningen (5)
- # liberator (1)
- # mount (22)
- # off-topic (8)
- # om (16)
- # onyx (53)
- # re-frame (11)
- # reagent (2)
- # specter (4)
- # testing (18)
- # untangled (51)
In db/default-db
(which initializes app-db), I fire off an HTTP request via goog.net.XhrIo and invoke a re-frame handler in its callback. However, the request must complete before re-frame has a chance to set up handlers because I see re-frame: no event handler registered for: ":coast". Ignoring.
. Am I misguided in my attempt to put a network request in the default db? (I was moved to do this because I set up a websocket in default-db too, and its callback also dispatches a re-frame handler, but I guess the websocket doesn't get any data before the handlers are all loaded.)
Ok, I initialized the value in default-db to nil, and in the view, I check to see if a subscription to that value is nil, and if so, fires off an HTTP request, etc.
Sounds like you are heading in the right direction.
Typically:
1. your main
normally does this (dispatch-sync [:startup])
2. In the handler for :startup
(1) some initial state is established in app-db which indicates the GUI should show "Loading ..." (or whatever makes sense for no data) and (b) HTTP call is made
3. When the HTTP response comes back it is handled by a further dispatch
4. In the handler for the response, you put in the real data. Which then causes the UI to render something more than "Loading ..."
@fasiha: ^^^^ So, I wouldn't be putting any HTTP GETs in default-db
@mikethompson: ahh, the lein template did put a dispatch-sync
in my app.core/init
! Thank you!
@danielcompton: Thanks!
@danielcompton: This example app made me a little confused however: https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/views.cljs