This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-05
Channels
- # adventofcode (50)
- # announcements (1)
- # asami (29)
- # babashka (56)
- # beginners (19)
- # calva (62)
- # cider (12)
- # cljs-dev (1)
- # clojure (42)
- # clojure-europe (214)
- # clojure-france (4)
- # clojure-italy (1)
- # clojurescript (58)
- # community-development (4)
- # cryogen (6)
- # cursive (7)
- # data-science (1)
- # events (3)
- # figwheel-main (1)
- # fulcro (21)
- # lambdaisland (3)
- # malli (17)
- # mid-cities-meetup (1)
- # off-topic (38)
- # pathom (3)
- # reagent (7)
- # reclojure (1)
- # reveal (15)
- # rewrite-clj (11)
- # shadow-cljs (30)
- # sql (21)
- # test-check (14)
- # tools-deps (1)
- # vim (21)
- # xtdb (5)
Is there a way to make qualified keywords from a string? Iām thinking of for example making ::a
from the string "a"
. Is the only way to type out the whole namespace in (keyword "very.long.namespace.name" some-string)
?
@hrmeyer What about:
user=> (defn qkw [s] (keyword (str (ns-name *ns*)) s))
#'user/qkw
user=> (qkw "a")
:user/a
I tried that, but when I called my function from core
, I noticed that *ns*
refers to the current namespace.
yes, *ns*
refers to the current namespace. ::a
also resolved in the current namespace.
could you give an example of what is the expectation when calling it with two separate namespace?
I might be misunderstanding something š I have a namespace/file myfile.clj where I define these keys, and do some operations on them. But I get a different result when I call this this function from core.clj.
when you call the function from core.clj it will use the value to which *ns*
is bound at that moment, which is foo.core
so the function is defined in namespace B but you are calling it from namespace A, but the namespace in the keyword should always be from B?
Yes, that is what I want to achieve š
in B you could do the following:
(def current-ns-name (ns-name *ns*))
(defn qkw [s] (keyword (str current-ns-name) s))
what's the best way of having an atom a
update when atoms b
or c
update? Is there something like merge-atom
? Or should I use add-watch
?
it's a good suggestion, but it would break encapsulation in my case; I'm now interested in the toy problem on how to merge them properly
@meditans https://github.com/martinklepsch/derivatives sounds like what you're after?
ok y'all make good points, so, let give some more context on the original problem: I'm using reagent, and I have a function that takes some data as a prop. Inside that function, I want to manipulate a local copy, and sync outside my program when the local state has some properties
so, I would prefer not to put all the state in one atom because that mixes up local and global state
but I don't know how to write that I want the local state to be either a result of the user manipulation, or the change coming from the global var, whichever came last
so basically I'd like something like r/with-let [local (r/atom global)]
, but which continues to post update to the value
in a re-frame subscription you could merge the component local and global state and then act on that
there's also the more low level reaction API for reagent and r/track, which could possibly offer a solution for this
yeah, you could also have a component which gets the merged state as props and merge that state in the parent
(this is the website hosting it: https://borkdude.github.io/re-find.web)
thanks! give me a minute to parse all this info; you're right that it could be a react antipattern, and in fact part of this is learning what the correct patterns are (I usually write FRP, in which this problem doesn't exist)
Hey, so i'm trying to identify the value of a parameter being passed to a function. Im using emacs with cider, however, when i run the function via the repl i'm only getting back the return value of the call, not the printed value. Anyone know how i can access this?
(defn- sign-request
([client req]
(println req)
(client req)
))
For example, i'm trying to identify the value of req@cgboal521 This value is printed in your cider REPL buffer
@cgboal521 You could also capture the value and then inspect it. E.g. like this: https://blog.michielborkent.nl/2017/05/25/inline-def-debugging/
Hmm, wasn't showing up but may be doing the wrong kind of repl execute in emacs. Cheers, will check that link
@cgboal521 This is also a nice read, if you want more: https://clojure.org/guides/repl/introduction
Cheers will take a look