Fork me on GitHub
#beginners
<
2019-07-25
>
stardiviner02:07:50

The commnd clj how to get it’s version?

alexmiller03:07:55

clj -Sdescribe

alexmiller03:07:26

the most recent is 1.10.1.466

stardiviner03:07:54

@alexmiller thanks

chetchan07:07:07

Hi folks, My first Q on here. So pardon if I don't get the format of asking correct. I have a small project that uses hugsql to get rows of data from a DB table. Now my problem is not being able to test my code repl, I am using IntelliJ + Cursive. Here is how my code partial looks

(defprotocol ETLJob
  (exec [this])
  )

(defrecord ETLJobImpl [big-query dw-db]
  ETLJob
  (exec [this]
    (f/attempt-all [_ (println  "Getting DB records")
                    dw-records (oracle-db/get-debtor-profile-records dw-db)
(prn dw-records)] 
)))

;calling the get-debtor-profile-records from my comment

(comment
  (let [dw-db (:boundary/dw-db integrant.repl.state/system)]
     (oracle-db/get-debtor-profile-records dw-db))       *;; Running this line gives me dev=> (let [dw-db (:boundary/dw-db integrant.repl.state/system)] (oracle-db/get-debtor-profile-records dw-db))
dev=> CompilerException java.lang.IllegalArgumentException: No implementation of method: :get-debtor-profile-records of protocol:*

   (exec (:job/etl integrant.repl.state/system)) *;RUnning this line alone doesn't work gives me dev=> (exec (:job/etl integrant.repl.state/system)) CompilerException java.lang.IllegalArgumentException: No implementation of method: :exec of protocol: #'scg.job.etl/ETLJob found for class: nil, compiling:*
  )

Any idea how I can test my code within repl. I am just in the dev ns right now that should load all my duct config. PS: Since this is my unit test I have setup all the values needed for the duct config in my ENV variables.

xi07:07:11

I guess (:job/etl integrant.repl.state/system) returns nil?

chetchan07:07:46

It returns CompilerException java.lang.IllegalArgumentException: No implementation of method: :exec of protocol:

xi07:07:12

You saw I chopped exec out? What does your (defmethod init-key :job/etl look like?

chetchan07:07:52

Oh, sorry. Yes. (:job/etl integrant.repl.state/system) returns nil

chetchan07:07:14

That looks like

(defmethod ig/init-key :job/etl
  [_ deps]
  (log-begin-end
    (map->ETLJobImpl deps)
    ::initialise))

xi07:07:36

Did you (go)? To initialise the integrant-REPL system

chetchan07:07:18

dev=> (go)
dev=> IllegalArgumentException No method in multimethod 'init-key' for dispatch value: :boundary/big-query  clojure.lang.MultiFn.getFn (MultiFn.java:156)

xi07:07:49

Well, that's another problem. Does (:job/etl integrant.repl.state/system) return something now?

chetchan07:07:50

Still gives me nil even after I removed the :boundary/big-query from the config

xi07:07:04

Try (reset)? Then the thing again

chetchan07:07:19

Thx, cleaned up my dev.edn of :boundary/big-query and now (:job/etl integrant.repl.state/system) works

xi07:07:34

Any luck with exec now then?

chetchan07:07:23

dev=> (exec (:job/etl integrant.repl.state/system))
dev=> CompilerException java.lang.IllegalArgumentException: No implementation of method: :exec of protocol: #'scg.job.etl/ETLJob found for class: scg.job.etl.ETLJobImpl, compiling:

chetchan07:07:40

Still gives me that error

xi07:07:55

ah but the class is right now, because at least you're calling it on a value now

chetchan07:07:34

Yes...seems like I can just run the line

(oracle-db/get-debtor-profile-records dw-db)

chetchan07:07:03

Is there some docs on how to use duct and integrant with repl?

chetchan07:07:16

Thx for your help so far...it has gotten me further along

👍 1
chetchan07:07:12

So there needs to be a (defmethod ig/init-key....) for every :boundary/abc inside the *.edns?

xi07:07:47

Yep think so; I guess you could (defmethod init-key :default) if you want to allow configuration of components you don't have. Can't see a reason to though

👍 1
xi07:07:14

bear in mind (reset) reloads from disk, so if you've eval'd stuff in from an editor session, that will get overwritten

xi07:07:03

I've not used Duct

chetchan07:07:26

Thx...I thought duct & integrant are used together...but seems I am using mostly IG only.

Ashley Smith10:07:34

Good morning everyone. I posted something in #figwheel-main but I didn't get any answers so I was wondering if anyone could help. I have a deps.edn file that looks like this:

{ :deps { org.clojure/clojure       {:mvn/version "1.9.0"}
          org.clojure/clojurescript {:mvn/version "1.10.339"}
          ring/ring-core            {:mvn/version "1.7.1"}
          ring/ring-jetty-adapter   {:mvn/version "1.7.1"}
          compojure                 {:mvn/version "1.6.1"}
          reagent                   {:mvn/version "0.8.1"}
          re-frame                  {:mvn/version "0.10.8"}}
  :paths ["src" "resources"]
  :aliases { :depstar
              { :extra-deps
                {seancorfield/depstar {:mvn/version "0.2.4"}}}
            :fig 
              { :extra-deps
                { com.bhauman/figwheel-main       {:mvn/version "0.1.9"}
                  com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}
                :extra-paths ["target" "test" "resources"]}
            :build {
              :main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]}}}
I've got a front end and a back end in the same project. I had the front end working well with figwheel-main, and the backend was undeveloped. I've done some work on the backend and added the ring dependencies and compojure, and all of a sudden my CLJS front end will not compile. If I comment out ring/ring-jetty-adapter everything compiles, so I was wondering why simply listing a dependency causes things to stop compiling and if there's some way of separating these dependencies?

Ashley Smith10:07:47

oh wow! Nice find!

Ashley Smith10:07:24

Specify jetty dependencies as the same version.. okay

Ashley Smith10:07:48

hmm I don't really know which deps to set the same version to, I only have one jetty dependency?

danieroux10:07:48

Or, bump up your figwheel to 0.2.3

Ashley Smith10:07:51

Front end is working

Ashley Smith10:07:55

lets check if the backend is

Ashley Smith10:07:42

It's working!! ❤️

Ashley Smith10:07:45

thank you!!!!!

xi10:07:31

Have you seen lein deps :tree?

Ashley Smith10:07:02

no I haven't. I'm not currently using lein either by the way 🙂

xi10:07:17

Ah whoops

naproxen11:07:21

:on-change #(swap! values assoc id (.. % -target -value)) i have a code but i don't udners this part do you know where can i find the related documentation of (.. % -target -value)

jakuzure12:07:31

Could someone explain why re-frame is considered great? Seems to me like I'm writing a lot of boilerplate still

Ahmed Hassan13:07:46

Check Fulcro too.

Ahmed Hassan13:07:32

What kind of app are you working on?

jakuzure13:07:00

Nothing in particular, just playing around with it. Thanks, I'll check out fulcro

Ahmed Hassan13:07:21

I've tried keechma, re-frame and fulcro.

Ahmed Hassan13:07:19

I liked Fulcro more than others.

manutter5113:07:55

What I like about re-frame: 1) It’s simple, 2) it’s explicit, 3) it’s functionally very pure, and 4) it separates concerns.

manutter5113:07:42

It’s simple: components don’t have to worry about digging through the app-db to find data; they just subscribe to the values they want. They don’t have to worry about updating a complex app-db, they just fire events. Subscriptions, done right, are often just looking up a value in a map.

manutter5113:07:29

It’s explicit: by which I mean, there’s not a lot of “magic” involved, like you get in things like Ruby on Rails. It may be a bit like boilerplate, but when you’re debugging, it helps to have everything laid out right in front of you, no mysterious “action at a distance” or behind-the-scenes black-box actions. (Yes, it does do some abstracting away of implementation details, but that’s fairly minimal, well-documented, and fairly easy to predict).

manutter5113:07:28

Functionally very pure: Side effects are restricted to event handlers and effects, and even then event handlers take in a state and return a state, so it’s still pretty functional and easy to test.

manutter5113:07:40

Separates concerns: It’s really nice that components don’t need to do complicated things in response to user interactions. Just dispatch an event reporting what the user did. The event handlers will take care of updating the app-db, or whatever else you need. And the event handlers don’t need to worry about layout or CSS styles or any of the things components do.

manutter5113:07:43

Also I love how you can make subscriptions that do form validation for you automatically, even complicated things like making sure the Total field equals the sum of the line item prices. No more worrying about “This field changed, now I have to trigger a validation on that other field, which depends on it.” Just take advantage of the built-in subscription functionality.

🍺 2
👏 2
naproxen13:07:14

@U06CM8C3V it's very detailed and structured reply. you may consider to publish it on medium or somewhere

😄 1
🚀 1
bronsa13:07:09

@m373h4n .. is a macro, (.. foo bar baz) is expanded to (.baz (.bar foo))

bronsa13:07:24

so that expression is equivalent to (.-value (.-target %))

🍺 1
naproxen13:07:45

ah thank you for the information

Lu13:07:31

Next time you can expand it like this : (macroexpand '(.. % -target -value))

🍻 1
naproxen13:07:08

this is useful thanks i didn't know how to expand 🙂

👍 1
Lu13:07:42

@shin From my personal point of view, re-frame is nice because it gives you structure.. it does not simplify your code, but it organizes it. By channeling all actions via dispatch and subscribe I think re-frame also tries to prevent you from doing something horribly wrong.. For example, you can access the db solely from your handlers and update it solely from events.. If you are absolutely impeccable, you could go without it and you would probably do very well.. but you still need to think of how you want the data to flow.. and that could take not a trivial amount of time.. go with re-frame and it's all already figured out for you...

👍 1
Crispin13:07:08

Personally (just my opinion) I'm not a fan. I like reagent. But re-frame is difficult to test. Has "global" state. And doesn't work with devcards.

☝️ 1
Ahmed Hassan13:07:03

@crispin Keechma is great alternative to re-frame.

Crispin13:07:30

Cool. Haven't heard of that. I will check it out.

dpsutton13:07:01

I miss my devcards workflow with a reframe project 😞

🍷 1
Jeevaraj MV14:07:09

@here do have any spell check in clojure

Jeevaraj MV14:07:11

Since I’m from ruby background In Ruby we uses rubycop gem

Jeevaraj MV14:07:26

Pls let me know

Nate Sutton14:07:40

there's joker and clj-kondo, if that's what you mean

borkdude14:07:29

@jeevarajmvsvg If you have any questions on how to use clj-kondo, just let me know in #clj-kondo

Jeevaraj MV15:07:24

Okay thank you

Jeevaraj MV15:07:32

Let me check

seancorfield21:07:55

:thumbsup::skin-tone-2: