Reputation: 1824
I am currently using the two following blocks of code to access nested values in ClojureScript:
(def response (re-frame/subscribe [::subs/quote]))
(def body (:body @response))
(def value (:value body))
(println value)
(def result (-> @(re-frame/subscribe [::subs/quote]) :body :value))
(println result)
(def lol (get-in @(re-frame/subscribe [::subs/quote]) [:body :value]))
(println lol)
Are there any better / more succinct ways of doing this?
Upvotes: 1
Views: 182
Reputation: 38922
Keys can be used as operators to retrieve its value like so:
(def lol (:value (:body @(re-frame/subscribe [::subs/quote]))))
(println lol)
However, I prefer the verbose way using a function as get-in
Upvotes: 2