Fork me on GitHub
#clojurescript
<
2016-06-11
>
joshjones04:06:35

hello all ... first post here so please forgive me if I mess it up. a question about cljs and namespaces

joshjones04:06:57

I used the lein template for reagent, so I have under my main directory the "src" directory. Under there I have 3 subdirectories: clj, cljc, and cljs. In src/cljs/charts/charts.cljs, I want to require a function found in src/clj/db/db.clj ... how do I require this?

joshjones05:06:33

FWIW, in the project file I have under :cljsbuid a :min and an :app, each which has a :source-paths where I added "src/clj"

escherize08:06:40

Am I missing something obvious here:

> (js->clj (clj->js {:a 1}))
;;=> {"a" 1}
> (js->clj (clj->js {:a 1}) {:keywordize-keys true})
;;=> {"a" 1}

escherize08:06:08

Nevermind:

> (js->clj (clj->js {:a 1}) :keywordize-keys true)
;;=> {:a 1}

escherize08:06:28

[x & opts] got me.

rauh08:06:04

Just updated my build scripts, does figwheel and cljs builds: https://gist.github.com/rauhs/2a02e5e04b5bd4e4b4b5

vinodgandamalla08:06:38

so , i need not include the namespace @rauh

vinodgandamalla08:06:08

hi , i am trying to use cljsjs/facebook packages in my build.boot i include the dependency [cljsjs/facebook "v20150729-0"] and in my app.cljs file i include the namespace [cljsjs.facebook] , iam getting the following error "No such namespace: cljsjs.facebook, could not locate cljsjs/facebook.cljs,"

rauh08:06:29

@vinodgandamalla: You don't need to require it. Just use the facebook API in your code

nasser11:06:51

next steps will include integrating e.g. into the ns form

nasser11:06:10

PRs and issues welcome!

pat11:06:48

@bhauman on node, 0.5.4-snapshot sends my test results to both the node process & my repl, is there a knob to disable printing to the repl?

bhauman12:06:00

@pat: before your test runner you will need to bind the print-fn to what you want it to be https://github.com/bhauman/lein-figwheel/blob/master/support/src/figwheel/client.cljs#L49

bhauman12:06:21

or around your test runner

joshjones21:06:45

My CLJS project has three subdirectories under src: clj, cljc, cljs. How can I reference a function in src/clj/db/db.clj from src/cljs/charts/charts.cljs ? (ns charts.charts .... :require [db.db :as db] does not seem to work.

potetm21:06:33

@joshjones: How is a JVM function supposed to work on JavaScript?

dnolen21:06:03

@joshjones: you cannot load .clj files in ClojureScript unless it’s a macros file

dnolen21:06:31

if you want to load it make it .cljc instead

joshjones21:06:58

Thank you for the answer and the patience -- this is my first cljs project.

joshjones21:06:12

Why did the reagent template create the clj directory then, I'm curious?

potetm21:06:45

Good question.

potetm21:06:00

It looks like reagent-template includes server-side stuff for you.

potetm21:06:28

So you would use that when you start to get your appserver set up.

dnolen21:06:08

@joshjones: there’s a pretty active #C0620C0C8 channel

joshjones22:06:44

thanks very much @potetm and @dnolen