This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-13
Channels
- # adventofcode (51)
- # announcements (1)
- # babashka (7)
- # beginners (45)
- # berlin (2)
- # bristol-clojurians (1)
- # calva (38)
- # cider (2)
- # clara (25)
- # clj-kondo (2)
- # cljs-dev (25)
- # cljsrn (3)
- # clojure (112)
- # clojure-dev (6)
- # clojure-europe (5)
- # clojure-nl (1)
- # clojure-spec (15)
- # clojure-uk (93)
- # clojurescript (29)
- # clojutre (2)
- # core-async (78)
- # cursive (24)
- # datomic (29)
- # figwheel-main (1)
- # fulcro (50)
- # hugsql (1)
- # hyperfiddle (1)
- # luminus (1)
- # malli (26)
- # off-topic (40)
- # portkey (12)
- # reagent (22)
- # ring-swagger (1)
- # shadow-cljs (56)
- # spacemacs (24)
- # tools-deps (68)
hello! how this translates to Clojurescript?
let response = await fetch('/article/fetch/post/user', {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify(user)
});
I have tried with
(def fe (js/fetch ""
#js {:method "POST"
:body "567985679865796579"
}))
but something does not work. It sends empty POST request from browser to the host but body is not included.how to check if value in map is a number or type of cljs.core.Delay
? will this work (if (= 'cljs.core.Delay (type val.....` ?
the data I have prints into REPL like this {:hash_ #object[cljs.core.Delay {:status :pending, :val nil}],
...
Hello, The documentation of swap! functions states:
Atomically swaps the value of atom to be:
(apply f current-value-of-atom args)
But when i try it in the repl, i got strange behavior with assoc function:
cljs.user=> (def a (atom {:a 1 :b 2 :c 3}))
#'cljs.user/a
cljs.user=> (apply assoc @a [:a 24])
{:a 24, :b 2, :c 3}
cljs.user=> (swap! a assoc [:a 24])
{:a 1, :b 2, :c 3, [:a 24] nil, nil nil}
On the 3 line i just do what the doc said: (apply f current-value-of-atom args). And i got the result i expected, but when i finally use swap!, i give a different result.
Do you think it's a documentation issue or i missed something?I've done a similar mistake in the past, and I've always wondered - where does the nil nil
pair come from?
Thanks for the answers, My original idea was to update multiple key/values at once with:
cljs.user=> (apply assoc {:a 1 :b 2 :c 3} [:a 24 :b 23])
Which actually works. How could i obtain the same behavior with the constraints that the key/values to update are in vec and the map to update is an atom?Thanks Isenjov,
(swap! a (partial apply assoc) [:a 24])
It works. I'm now considering to use a map instead š
(swap! a merge {:a 24 :b 32})
I have an implementation namespace like lib.impl.foo
that has some macros + runtime functions (itās a .cljc file).
in my lib.core
namespace, I have a macro foo
that emits a call to lib.impl.foo/bar-macro
which emits a call to the lib.impl.foo/baz
function.
When I use the lib.core/foo
in another namespace, I get a bunch of warnings about āUse of undeclared var lib.impl.foo/baz
ā
This makes sense to me, since itās emitting a bunch of calls to a namespace that doesnāt appear in that ns requires. However, Iām not sure how to solve this problem without moving everything in lib.impl.foo
into lib.core
Any ideas?
mind if I ask what an "implementation namespace" refers to? (saw them inside helix, too)