Fork me on GitHub

I’m trying to figure out which frameworks are most popular for SPAs and Native applications. I know people like reagent and reframe, but I like more. After hacking together JS libraries (eg. falcor + mobx + react) it’s a breath of fresh air. I know that fulcro exists, but I find it too heavy weight. Where are the best resources for digging into the library, I find the GitHub wiki very lacking. It also makes me feel worried about the level of support for the library.


om next seems cool, but last I checked it doesn't have the momentum and dev energy that reagent does


so use it if it's useful, but maybe don't expect the amount of maintenance and feature work you'd see with a more popular lib? - looks like the last commit on the repo was over a year ago, which is ancient in js years

Silenced Ego02:08:30

As a newly grad, multi-lingual programmer with some self taught knowledge in clojure, how difficult is it to find a job in clojure in USA?

hamid tsh11:08:13

hi. i create a websocket using http-kit as a server side and use clojurescript as client-side. in clojurescript i have ( (set! (.-onmessage socket) (fn [msg] (js/console.log msg))) now when i print type of msg i get it's messageٍEvent. now how can i change this to string?


Needs another .-data (fn [msg] (js/console.log (.-data msg)))

Ashley Smith13:08:37

So a while ago people helped me start learning about security and I followed this tutorial to get signed JWT tokens: and the source code: I have some more questions though. I have my server creating and giving out tokens to successfully authenticated users now, I understand that. But now, I need some help actually using the token, and I think in order to do that I need to learn what line 81 is fully doing.

(def secret (nonce/random-bytes 32))
;; Create an instance of auth backend.
(def auth-backend (jwe-backend {:secret secret
                                :options {:alg :a256kw :enc :a128gcm}}))
    (wrap-authorization $ auth-backend)
    (wrap-authentication $ auth-backend)
What exactly is secret? Its not a users password or anything, so I'm not quite sure how it fits. Secondly, auth-backend is wrapped around the handler, but I don't really know what A. The difference is between the authorization and authentication middleware, and how exactly these operate. There is a function called authenticated?, does the middleware handle the validation etc and then pass that result to this function as a bool for me to use? What if I want to know which user is authenticated etc? I'm struggling to follow the flow of the source code. I feel like im close but I just need a little push


@ashley Its a Nonce, mainly used initialize a crypto session. It needs to be random so that each session cannot be replayed.

Ashley Smith13:08:18

to put it bluntly, is a nonce kind of like a key in a cipher? And then you just use a new nonce each session to make sure people don't break the authentication barrier as easily?


so its to make a session unique, think of it as the initial seed to begin the crypto and the stuff following is generally a message that your gonna encrypt and are not so random


if the initial value of the ciper isnt random enough, its susceptible to


the key in the cipher is something that the user specifies like a password

Ashley Smith13:08:34

I'm learning! Thank you 🙂


Crypto is a world on its own, one never stops learning 😄


and for the wrapper, the ring middleware adds a Header to the response to which the client needs to present a valid token back


see for more info. found this quite informative

Ashley Smith13:08:58

I wish my uni taught it

Ashley Smith13:08:04

so you wouldn't have to

Ashley Smith13:08:16

you wouldn't believe that im a final year computer science student


Well, most of the crypto stuff I picked up after college too. 😄

Ashley Smith14:08:19

(let [claims 
              { :usr (keyword username)
                :exp (time/plus (time/now) (time/seconds 3600))}
            token (jwt/sign claims secret {:alg :hs512})]
So after that site you showed me I understand this a lot better, the username is built into the token directly so that helps, and it also helps me place other items in it if I need to. The next thing I need to learn though is how to actually work with this token in code, as it's just a long string of characters. Should I be decoding this on clientside to get information like the userid or whatever?

Ashley Smith14:08:51

either way, I'll probably store it with re-frame or something, and then I just need to send it back with my requests


the authenticated? fn does the verification of the Authorized header

Ashley Smith14:08:47

I just need to learn how to actually put stuff in that header


verifies that the token sent by the client is a valid one


you want to know how to respond to the server from the client?

Ashley Smith14:08:27

(defn- make-http-get-request
  "Creates a HTTP-GET request"
  [uri on-success on-fail]
  { :method           :get
    :uri              (str "" uri)
    :timeout          8000
    :response-format  (ajax/json-response-format {:keywords? true})
    :on-success       [on-success]
    :on-failure       [on-fail]})
Would the token be inserted somewhere here I imagine?


what lib are you using on the frontend?


to make the request?


you basically need to add a header called Authorization having the value Token <the token here> <- the whole thing including the space after the Token needs to be the value of the header

Ashley Smith14:08:28

oh I thought that was pseudocode, my bad

Ashley Smith14:08:33

I didn't take it literally

Ashley Smith14:08:01

I'm using re-frame.http-fx

Ashley Smith14:08:30

so let me go dive into the docs and find out how to make that header


yeah, im not too familiar with that lib, im looking it up too

Ashley Smith14:08:08

out of interest, what do you use? 🙂


it looks like you can just have a key called :headers


and the value [:Authorization token]

Ashley Smith14:08:31

ah you beat me to it I just found it


the token could be (str "Token " token-from-server)


> out of interest, what do you use? To be honest I'm not much of a frontend person, just know enough to get it going. Mostly servers and infrastructure and yes being in Berlin, some amount of crypto and security too 😛

Ashley Smith14:08:18

im just learning so I'm going about the whole thing

Ashley Smith14:08:35

I kind of think I'd prefer to do backend, but I also think I'm not good enough yet 😛


Happy to help 😄


what's the current state of the art wrt Clojure web servers? immutant and http-kit look great, especially doing websockets, but look untouched in a while. is that because they are stable or abandoned? should I be looking at jetty instead?


i'm thinking I'm going to go with ring-jetty since it looks the most maintained

Jamie Rumbelow16:08:33

Hi all! I’m getting quite frustrated with; for instance, empty queries throwing an exception. I’m used to less low-level DB layers (am formerly a Laravel developer). I’m enjoying using HoneySQL to generate queries; what sort of layers of abstraction exist for executing them?


you could try, it’s the successor to which is much improved, but equally low-level


as for higher-level stuff the only two I’m aware of are and, and I haven’t used either so I can’t vouch for them

Jamie Rumbelow18:08:52

good starting point – thank you!


I use next jdbc with honeysql and it's been great so far

👍 1

hey guys, I’m trying to create my own flatten function ( improve my clojure skills )

(defn my-own-flatten [tree]
  (loop [[h & t] tree
         result []]
       (nil? h) result
       (coll? h) (recur h result)
       :else (recur t (conj result h)))))
the function is not working as expected, could you guys give me a hand ?


fixed my function

(defn my-own-flatten [tree]
  (loop [[h & t] tree
         result []]
       (nil? h) result
       (coll? h) (recur t (doall (concat result (my-own-flatten h))))
       :else (recur t (doall (concat result [h]))))))


Curious: why are you using doall? That's for controlling side-effects.

Ashley Smith23:08:14

Hey everyone! I need some help implementing the following in reagent with JS interop:

var simplemde = new SimpleMDE({ element: document.getElementById("MyID") });
Here's my crack at it, but I can't even get the element itself to print - whenever I involve the SimpleMDE code I get TypeError: e is undefined
    (println (.getElementById js/document "foo"))
    ;(js/SimpleMDE. {"element" (.getElementById js/document "foo")})

David Pham23:08:03

You could convert the Clojure map to js with clj->js

David Pham23:08:59

Or use #js before your map to indicate that the following map is a JavaScript map

Ashley Smith23:08:13

@neo2551 even the (println line returns nil so I don't know really where I'm going wrong

Ashley Smith23:08:22

thanks for trying to help though as I'm out of ideas really

David Pham23:08:12

Did you create the page and tested the JavaScript command in the google console?

Ashley Smith23:08:24

no, that is a good shout!

Ashley Smith23:08:16

It works in the console

Ashley Smith23:08:23

so I just need to learn how to do it in clojure

Ashley Smith23:08:51

does the textarea actually exist by that println statement?

David Pham23:08:52

Actually no I don’t think so

David Pham23:08:03

I would first make sure your component is mounted

David Pham23:08:11

And then in the repl test your commands

Ashley Smith23:08:31

what do you mean by mounted? Sorry I'm not sure of the technicals of all this 😞

David Pham23:08:41

Reagent is a wrapper around react, so we use react life cycles methods in the background (the third form of components of reagent is about defining the whole life cycles)

David Pham23:08:23

To answer: mounted means that your components has been included/attached to your actual DOM (ie you can see it in the source file)

David Pham23:08:57

[disclamer: I learned reagent/cljs 6 months ago]

Ashley Smith23:08:07

this is the first time I've had to do this, I guess because I've never needed to get something by ID after it's in the DOM

Ashley Smith23:08:16

thank you for bringing this up, I'll keep reading

Ashley Smith23:08:26

maybe its just too late for me though I'm tired

David Pham23:08:32

So, to help you: first make a simple 1 form component with reagent with an idea

David Pham23:08:48

Then try to get it from your dev console in your browser in JavaScript

David Pham23:08:02

And then try to reproduce the step in your repl in cljs

David Pham23:08:03

Then write a function out of it. My guess is you will need to use a reagent/atom to store the state. I usually deal with that by using re-frame events and database

Ashley Smith23:08:03

yeah re-frame is great

David Pham23:08:03

This article is interesting as well

Ashley Smith23:08:12

I just didn't think it'd be so hard to do something like this tbh

David Pham23:08:22

Actually the reason is your trying to grab the value while your component is not even created yet. So it is normal that your compiler is unhappy :)

David Pham23:08:08

I am still a beginner, but I can tell you it gets easier quickly.

Ashley Smith23:08:55

it means a lot that you're trying!

David Pham23:08:11

(defn code-mirror []
     (fn [comp]
      (js/CodeMirror. (reagent/dom-node comp)))
     (fn []
       [:div])})) ;; this div will get returned by `dom-node` above

David Pham23:08:17

Change the reagent-render function to your hiccup vector and the :component-did-mount function to your JavaScript calls

David Pham23:08:30

Or use the node directly