This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-10
Channels
- # beginners (40)
- # boot (307)
- # boulder-clojurians (2)
- # carry (3)
- # cljs-dev (3)
- # cljsjs (16)
- # clojure (42)
- # clojure-greece (3)
- # clojure-russia (10)
- # clojure-uk (3)
- # clojurescript (116)
- # community-development (1)
- # component (5)
- # conf-proposals (2)
- # core-async (1)
- # crypto (2)
- # cursive (3)
- # devcards (1)
- # events (1)
- # hoplon (123)
- # om (28)
- # onyx (17)
- # pedestal (3)
- # proton (1)
- # re-frame (18)
- # reagent (26)
@seancorfield @codonnell Thanks, that helps a lot!
oooooooh I just found event emitters. This is what I needed \o/
but http://github.com/clojurewerkz/eep hasn't been updated in 2 years š
@eslachance: I've never used anything like that, what do you want to use them for? Looks interesting!
@straistra You need to slurp at macroexpansion time https://gist.github.com/noprompt/9086232
@seancorfield Thanks for the helpā¦ just to close the loop, hereās the function. I modified it a bit to keep the embedded maps intact rather than rolling their stats into to top-level map.
(defn summarize [data acc]
(reduce-kv (fn [acc k v]
(cond
(number? v) (update acc k (fnil + 0) v)
(map? v) (assoc acc k (merge-with summarize (k data) (k acc) ))
:else acc))
acc data))
Now with my seq of records āsā I can just (reduce summarize {} s)
. Works a treat, thanks a lot!
@shaun-mahood I'm just so comfortable with events in node.js, that I want to use something similar in Clojure. I might end up using core.async
or clojurewerks/Meltdown
I dunno yet.
@eslachance: Have you thought about trying Clojurescript with NodeJS? My first real project was in CLJS and it was pretty nice being able to use the JS interop.
Well. let me explain the idea first.
My "bright" idea is to ambitiously create a library for bots in Discord
Which sits between the Discord API, that uses both websockets and get/post/put events
And the end-user creating a bot that will wait for specific events from the library (which I call Dithcord, because I'm funny like that). So, say the API sends a websocket event with a new message, the person making the bot would add an event listener that waits for a "message" event, and do stuff.
So like
(mr/on reactor ($ "message") (fn [message, server] (do something with message)))
or
(mr/on reactor ($ "newUserOnServer") (fn [event] (welcome the new user)))
(that's with Meltdown, just pulling examples from the readme)
From what I've seen most people just roll their own "library" by interacting directly with the REST API and websockets, but I want to make this a semi-friendly helper library that is as feature-complete as the other ones (there's probably 2 dozen libs out there, 4 are in node.js)
Does that make sense @shaun-mahood ?
I have to figure out websockets first and how to communicate/ handle events, but I have stylefruits/gniazdo
for that I just need to... well... kinda learn clojure š
@eslachance: Sounds like fun!
For the project I want to do ultimately I'll probably be using clojurescript with re-frame and stuff but I really, really like the idea of making my own library and then making tutorials and videos for it. That's my "thing" š
Very cool, aways need more of that.
I needed some help setting up cider
for some reason I am not getting any completion suggestion
My setup-clojure.el: https://gist.github.com/rahulpilani/965a8ed0d1510654d8658d4c3601ca92
Yessss I have a websocket "client" in clojure talking to a websocket server and they're pinging each other. \o/ success
Alright. first real noob question. I have a ping-pong
function that needs to be called from within my websocket... but it needs to call the websocket send-msg. This is my first real challenge figuring out how to work with clojure's "top to bottom" definitions (aka "you can't define a function before creating it). How do I call ping-pong from my socket (:on-connect) and call ws/send-message from ping-pong?
(defn ping-pong [delay]
(go-loop []
(printf "Sending a ping request")
(ws/send-message "ping")
(recur)))
(def socket
(ws/connect
""
:on-connect
(fn) [] (ping-pong 5000)
:on-receive
(fn [message] (receive-message message))
:on-error
(fn [error] (handle-error error))))
wait do I just need to pass the socket?
(or ws
?)
@eslachance Iām not following specifically what you are doing above, but Iād add that you can use declare
to side-step what I believe you describe as the ātop to bottomā issue.
Ah ok so declare
is like a placeholder?
@eslachance Yes, thatās roughly how I think of it mentally. Itās like saying: This var will be defined later on.
Thanks! š
Yeah I'm still figuring things out. I think the "order" thing is probably why the code I'm basing myself on is using async channels and not what I'm trying to do.
my original socket ping/pong is still going strong though š