Saving the value of an atom

127 views
Skip to first unread message

Rickesh Bedia

unread,
Nov 23, 2016, 8:05:15 AM11/23/16
to Clojure
(defonce car (atom ""))

(defn car-colour [ ]
  [:div
   [:div.container
    [:div.span12
     [car-form car]]]
   [:div.container
    [:div.span12
     "The car colour is: " @car]]
   ])

I have this function where you type in the make of a car and then this goes to a database and returns the colour of the car.

Is there a way of getting the value of @car to use in another function?

For example, to put the make of car and colour into a table. When I try to use @car in my table function it doesn't work.

Also is there a way to save these values in the table so if I called the car-colour function on another make it would add that to the table as well

Alex Miller

unread,
Nov 23, 2016, 8:32:56 AM11/23/16
to Clojure
In what way does it not work?

Rickesh Bedia

unread,
Nov 23, 2016, 10:03:27 AM11/23/16
to Clojure
When I put @car into my table the value doesn't show?

James Reeves

unread,
Nov 23, 2016, 10:25:14 AM11/23/16
to clo...@googlegroups.com
Are you setting your atom with a "swap!" or "reset!"?

Is this a normal atom, or are you using Reagent?

- James

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Miller

unread,
Nov 23, 2016, 12:10:28 PM11/23/16
to Clojure
Your code creates the atom with an empty string, so it would be correct for it not to show anything.

You are not providing enough information for us to help you.
Reply all
Reply to author
Forward
0 new messages