This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-25
Channels
- # adventofcode (3)
- # aleph (24)
- # architecture (8)
- # beginners (53)
- # boot (34)
- # cider (7)
- # clara (68)
- # cljs-dev (6)
- # cljsrn (3)
- # clojars (10)
- # clojure (71)
- # clojure-germany (2)
- # clojure-italy (10)
- # clojure-nl (25)
- # clojure-serbia (4)
- # clojure-spec (13)
- # clojure-uk (48)
- # clojurescript (31)
- # core-async (62)
- # cursive (13)
- # datomic (4)
- # duct (76)
- # editors (4)
- # fulcro (2)
- # immutant (1)
- # instaparse (1)
- # jobs (1)
- # lein-figwheel (1)
- # mount (1)
- # off-topic (12)
- # onyx (8)
- # re-frame (10)
- # reagent (84)
- # reitit (2)
- # ring (2)
- # shadow-cljs (159)
- # spacemacs (2)
- # specter (17)
- # sql (14)
- # tools-deps (10)
- # yada (15)
the missing step there is a mapping like {:val-1 [:prop-1] :val-2 [:prop-2] :val-3 [:prop-3 :nested-prop-1]}
so it knows where to put them by key
but that's still not as simple as just having the map literal with the values in the right places, so if you don't need the flexibility don't do it this way
I see it now. The only issue I have with my map literal is I am repeating it 3 times, and there is only 1 property difference for each. It just did not feel idiomatic to do this.
OK - in that case you can use the assoc-in / lookup to abstract it and reuse the repeated behavior, but whether it makes sense in your code is for you to figure out of course
True, Thanks!
Hello Guys, I currently work with ruby on rails and I really want give clojure. Do you guys recommend any books/videos/tutorials for a clojure newbie with rails/spring background?
Books and real world project examples: https://twitter.com/tmkjone/status/998249106454827009
@stardiviner it’s java interop, calling the close function on ByteArrayInputStream
@gklijs how can I know java interop calling the close
function on which object like ByteArrayInputStream
?
Cursive knows, I have no experience with other ide’s. Also with intellij it’s easy to go to the sources of ByteArrayInputStream
I see. Thanks
Sure. Thanks
I am using Soda-Ash (interface between reagent and semantic-ui-react) - Has anyone got the Sidebar working. I am struggling how to implement this using soda-ash.
@klaus.azesberger The #js
isn't nested automatically
thx 🙂
ah and the head.js import was missing too. now it works. gonna pr this. thx a lot for the quick help ❤️
@mhsmit See my comment in this issue, there is an example of a sidebar https://github.com/gadfly361/soda-ash/issues/10
What's the best way to handle an expiring oauth token in Clojure? I'm writing a simple REST API client to learn clojure, but I don't really know the best way to keep / replace the oauth token when it expires. (It lives 30 minutes) I have something like this {:client-id "123455689" :client-secret "1234512345" :token nil) I make a call to the authentication API, and get back the token and expiration time. I thought about just adding those properties to the map, but again i'm not sure where to put the map and how to mutate the token / expiration.
A simple place to start would be to use core.cache
Though that might be more sensible if you had e.g. multiple expiring tokens you were trying to manage
It sounds like you want an atom in which to store your client state
with core.cache you'd need an atom - it doesn't handle persistence, just the cache management logic
Hi, I am working in a project where I connect to a websocket API and then subscribe to different channels and keep the state of that subscriptions, and also state related to the messages incoming. There are different levels of “calculated state”, so I was planning to have different agents. One of them even needs to (send) to itself sometimes, depending the messages coming from the websocket connection (saved in one of the agents too, as needs to be replaced for new connections sometimes), and also execute side effects inside the agent. I was thinking on initialize each of the agents with an object that references all the agents in the “platform” (they are around 3 to 5, still deciding), thus having references to themselves in the value (and to the others), so they can send data to each other. Is this a good / bad practice? Any advice on how to handle this situations? Any different / better approach? Thanks!
an alternative to agents would be core.async, which is built around channels and events rather than mutations to an object in a container
so instead of sending a function that takes your agent and returns the replacement for the data in the agent, you send a message that is consumed by someone listening to that channel, which then integrates the data as it likes, optionally sending more messages
Yes, it’s another option I had in mind, but I struggle to figure out how to save state then combined with reading from channel. Maybe atoms? And sync change them on the loop for reading from a channel?
if you need to make the data globally visible outside the go block, that would likely be the simplest option yes
it should be doable with agents, but anecdotally I've seen complex things like this done successfully in core.async and never with agents
another pattern is a thread containing a reduce over some input source that updates an atom inside
I've seen this sort of thing with kafka for example
Thanks @noisesmith, will try the core.async approach. As for the thread containing a reduce, do you have any example of that? Don’t really see what you mean there
something like (future (reduce (fn [state input] (swap! external-store process state input)) @external-store (input-seq))
where the hypothetical process
function takes the external state, the reduce local state, and the next input as args and returns a value used by both the external store and the next reduce step
hello, when printing a sequence, how can i remove the surrounding parens or surrounding #{set} braces?
(apply println c)
gives me strange results, i'm trying to (println (str "your results are " (seq (first (result-set)))))
well you called str, use string/join to remove parens at that level
why do you want to call str though?
What's best practice for printing to stdout?
user=> (apply println "your results are:" (range 5))
your results are: 0 1 2 3 4
I just don't know why you called str, and calling str is why apply println didn't work
Aha, I don't need to call str at all! 😃
although apply str interleave did the trick, too.
but string/join does that, and is purpose built for it
could someone help me understand how this code isn’t circular
(extend-type default
pt/IPromise
(-map [it cb]
(pt/-map (resolved it) cb))
It seems to me that -map
is calling itselfit's calling the same method on a different object
if resolved
on a promise returned the promise, this method looping wouldn't be your biggest problem