This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-07
Channels
- # aleph (8)
- # beginners (16)
- # boot (5)
- # cider (22)
- # cljs-dev (15)
- # clojars (10)
- # clojure (94)
- # clojure-dusseldorf (1)
- # clojure-france (57)
- # clojure-greece (1)
- # clojure-spec (9)
- # clojurescript (15)
- # core-async (6)
- # cursive (11)
- # datomic (10)
- # emacs (6)
- # funcool (1)
- # hoplon (1)
- # off-topic (5)
- # re-frame (8)
- # spacemacs (8)
- # specter (4)
- # unrepl (10)
- # vim (5)
@lepistane I should mention though, that Joy of Clojure is "advanced" in that it uses more less-known functions to produce very concise code. It's not advanced in the "let's use a monadic stack to transform a free applicative into a dual functor" (yes, I made that up). So you'll stare at the code a lot, but by breaking it down and thinking of how the data flows, it'll make sense.
I can't find it now, but I remember the JOC's implementation of the Game of Life requiring me to sit and think about it for about an hour before I said "oh wow..." and it suddenly all made sense.
how can it be, that in a cljs-function you write a function without a function body but only with a map of keywords like this?
(reg-event-fx
:contract/fetch-compiled-code
interceptors
(fn [{:keys [db]} [on-success]]
{:http-xhrio {:method :get
:uri (gstring/format "/contracts/build/%s.json"
(get-in db [:contract :name]))
:timeout 6000
:response-format (ajax/json-response-format {:keywords? true})
:on-success on-success
:on-failure [:log-error]}}))
@timok {} in clojure or clojurescript is a hash-map literal value
@tbaldridge great!! i am going to read joy of clojure next!! THANK YOU SO MUCH!
inside a value binding, it's a destructuring of the input
but in a function you would have some kind of body where something is done, right? in this eventhandler above there is only a map in the function-body. what am i missing?
ok...I got it...the on-success is supposedly a function so there is a request and on success the function in on-success is called.
a map as a function body is valid - it just means "when called, create and return this data"
on-success is not called by that code
it is returned under the key :on-success
I don't know this context well enough to say for sure, but I'd hazard a guess that hte hash-map is used to create the parameters for an xhr, and the on-success is registered as the xhr success callback
but someone else is doing that, somewhere else