This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # admin-announcements (2)
- # beginners (35)
- # boot (353)
- # capetown (1)
- # cider (1)
- # cljs-dev (41)
- # cljsjs (3)
- # cljsrn (3)
- # clojure (118)
- # clojure-austin (12)
- # clojure-russia (17)
- # clojure-spec (21)
- # clojure-taiwan (1)
- # clojure-uk (91)
- # clojurescript (80)
- # clojurex (1)
- # cloverage (3)
- # datomic (66)
- # devcards (2)
- # events (2)
- # garden (6)
- # hoplon (54)
- # jobs-rus (1)
- # keechma (1)
- # lein-figwheel (4)
- # leiningen (3)
- # luminus (3)
- # off-topic (7)
- # om (4)
- # onyx (53)
- # other-languages (17)
- # proton (7)
- # protorepl (4)
- # re-frame (123)
- # reagent (1)
- # ring (6)
- # rum (2)
- # spacemacs (1)
- # specter (21)
- # testing (1)
- # untangled (1)
- # yada (42)
@leo.ribeiro: I suggest using the real DB in tests if they must include CRUD operations. Not doing so always gave me trouble.
If you can encapsulate the database interactions in a protocol, you can do that and reify an in-memory impl for your tests. If you can’t, use a real database instance.
Any other real noob beginners out there, I wanted to share my current method of learning which seems to be going quite well. I started with 'Clojure for the Brave', which went well, but I found that the concepts weren’t cementing as quickly as I would like, so I went through some ‘4Clojure' (I use the mobile app) problems, until i got stuck, and then went back to 'Clojure for the Brave'. This really helped me to gain some knowledge, practice (cement), gain more, practice (cement more), rinse, repeat. Highly recommend if your brain works the same way.
hey all, newbie clojure compilation/ops question.
I’m trying to get a clojure application I wrote live.
to do that, I’d like to use lein to package up an uberjar. for whatever reason, lein is seemingly executing the
-main function in my application when I run
this is a problem because I’m going to be building the jar on my ci server, which doesn’t have the same privileges as the eventual application server.
so, is there any way to compile clojure code without executing it? is there something I’m missing here about what’s happening under the hood?
yep that wasn’t the issue. sorry for not following up. I had a
System/getEnv call in one of my functions without the env variable specified when I ran
lein uberjar. I assumed I could define that env variable at runtime, not that it was a requirement at compile time. the
System/getEnv call returned a nil, which caused a NPE, which broke compilation somehow? still piecing through that
The solution we implemented was to put calls like
System/getEnv into a function that gets called at runtime. e.g.
interesting, will def try that. weird that one level of function nesting prevents the form from being evaluated
I don't know of any programming languages where function bodies are evaluated before they're called.
well don’t you have to recursively evaluate all the forms and generate a class for each function?
If you have
(def thing …) then the body will be evaluated at compile time so that the initializer for
thing can be determined. If you have
(defn thing …) then at compile time you are just producing a class and a method — the function is not actually called. Does that help @mss?
so follow up question: what’s the idiomatic way to make environment variables work with component’s model of calling
alter-var-root on a var?
start is called, that’s where you need to "build" everything your app needs, so that’s when you would call
If you have code that doesn’t get passed the system component, one "hack" you can use is to have
(def my-state (atom nil)) and have the
reset! it to the value it needs to have. Then the non-component code can do
@my-state. But that’s a "hack" that should be avoided! 🙂
(we’ve had to do this in our legacy code as we’ve slowly adopted Component piecemeal)
I'm trying to follow the modern-cljs tutorial, and I'm getting an error when trying to set up my own handler using compojure as per https://github.com/magomimmo/modern-cljs/blob/master/doc/second-edition/tutorial-09.md#the-handler
The first few lines of the traceback look like
java.lang.NullPointerException at ring.middleware.reload$wrap_reload$fn__977.invoke(reload.clj:22) at ring.middleware.content_type$wrap_content_type$fn__448.invoke(content_type.clj:30) at ring.middleware.not_modified$wrap_not_modified$fn__475.invoke(not_modified.clj:52)