This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-06
Channels
- # aws-lambda (8)
- # beginners (49)
- # boot (13)
- # braveandtrue (2)
- # cider (12)
- # cljs-dev (15)
- # cljsrn (2)
- # clojure (143)
- # clojure-italy (8)
- # clojure-nl (17)
- # clojure-spec (22)
- # clojure-uk (21)
- # clojurescript (145)
- # code-reviews (1)
- # cursive (33)
- # data-science (14)
- # datomic (25)
- # emacs (3)
- # events (1)
- # fulcro (48)
- # graphql (1)
- # onyx (15)
- # perun (5)
- # play-clj (2)
- # protorepl (1)
- # re-frame (27)
- # remote-jobs (3)
- # ring (3)
- # rum (7)
- # shadow-cljs (87)
- # specter (4)
- # test-check (14)
- # testing (2)
- # tools-deps (9)
Does anyone know some nice source on how Clojure prevents dead-locks and concurrency problems with managing database? Want to use it to show my team why Clojure can fix our problems
If the deadlocks are happening on the database I don’t know how / if Clojure can help with that much. Unless the database is Datomic 🙂
Yeah, I'm sorry for not clarifying it, I meant using Clojure with Clojure related tech stack such as Datomic
clojurescript set background color?
(defn simple-component []
[:div
[:p "I am a component!"]
[:p.someclass
"I have " [:strong "bold"]
[:span {:style {:color "red" :background-color "black"}} " and red "] "text."]])
[simple-component]
right on. i mean using (set! ... )
haha xD thank you
(set! (.-innerHTML element) text) works great, but i cannot figure out the syntax to change backgroundcolor or even color (font color) for that matter
unless you are using a proper DOM management lib, in which case it's a no-op because someone else is going to clobber your DOM :D
(and you end up with something like what Sen suggests above)
(set! (.-backgroundColor (.-style (.getElementById js/document "title"))) "blue")
works
okay, i had messed up the syntax completely: (set! (whatever element thing sub thing) prop)
... had my props living nestedly
nevermind, i don't know why it works in a live repl and not in my actual code lol
are you using something like reagent or om?
OR I was editing code in a conditional that never eval'd to true!
very barebones at the moment. lol gotta laugh at yourself sometimes.
what kind of properties?
the XY is I have js code that looks like this:
ctx.fillStyle = 'rgb(213, 224, 236)';
ctx.strokeStyle = '#cecece';
ctx.beginPath();
ctx.moveTo(0, 0);
because that’s just how the 2d context object’s api works. doto
would be nice (i think) to clean up all of the method invocations, but it isn’t clear if it is possible to intersperse the lines where you set properties on the objectyeah, but you'd likely need a function helper to get ctx into the right argument position
(for the assignments that is)
and then set! might be a macro which means actually a macro helper
@lee.justin.m this works perfectly with the goog.object api
(cmd)cljs.user=> (def o #js{})
#'cljs.user/o
(ins)cljs.user=> (doto o (goog.object/add "foo" "bar") (goog.object/add "baz" "quux"))
#js {:foo "bar", :baz "quux"}
(ins)cljs.user=> (.-foo o)
"bar"
(ins)cljs.user=> (.-baz o)
"quux"
so I guess goog already wrote that helper function I was thinking of
yea okay i just got to a similar place by writing a oset
function that wraps goog.object/set
I wonder what the difference between g.o/add and g.o/set is
oh, add is strict about the key being absent, so set is probably a better choice
my brain has never really liked using string literals as l-values but i guess is should just get over that
it would be trivial to make something that accepts a keyword and just calls name under the hood
while you were at it you could let it accept var-args like assoc, and use doto :D
(defn oassoc [o & kvs] (doseq [[k v] (partition 2 kvs)] (g.o/set o (name k) v)))
something like this(cmd)cljs.user=> (require '[goog.object :as g.o])
nil
(ins)cljs.user=> (defn oassoc [o & kvs] (doseq [[k v] (partition 2 kvs)] (g.o/set o (name k) v)) o)
#'cljs.user/oassoc
(ins)cljs.user=> (oassoc #js{} :foo 1 :bar 2)
#js {:foo 1, :bar 2}
LGTMI learned it from let - or a variation of it - IIRC
oh, destructure, which let uses
for java to run it, don't use uberwar, use uberjar
uberwar is for passing the object to an external container
usually with an uberwar you are going to pass the thing to apache tomcat (what amazon's elastic beanstalk uses) or to a jetty server
@noisesmith, thanks!