Fork me on GitHub
#clojurescript
<
2015-10-06
>
oskarth09:10:06

Is cljs.build.api/watch supposed to work for individual files in current directory? It's not reloading if I watch a single file, but if I put it in a directory (or watch current directory) it reloads. Couldn't find anything in JIRA, and according to https://github.com/clojure/clojurescript/blob/3ecf5aff4151b10d8abf2376f8fae735c61f28a6/src/main/clojure/cljs/closure.clj#L473 a file is compilable, which seems to be the only thing that the watch function requires. There might be something in the closure/watch function in how it checks for file changes.

oskarth09:10:03

Can submit a bug report, but wanted to check here first

oskarth09:10:35

Current hypothesis: namespace isn't matching path interpretation, which works ok for some things but not for watching it.

sander09:10:19

when using cljs in ios, is it possible to keep the cljs process running in the background (so even when the app is not shown)? not very familiar with ios dev, so i'm not sure what the sdk limitations are

oskarth10:10:49

Short write-up to clarify the above problem: https://gist.github.com/oskarth/de185c3e7e108af54619

thheller10:10:47

haha oops, wrong window šŸ˜‰

sander11:10:59

clojurescript:~/src thheller$ _

oskarth11:10:47

Talking to myself here, but one option would be to pass in a an option (or detect that source is just a file) and add a filter in this section: https://github.com/clojure/clojurescript/blob/3ecf5aff4151b10d8abf2376f8fae735c61f28a6/src/main/clojure/cljs/closure.clj#L1799-L1804

oskarth11:10:57

Maybe this belongs in clojurescript-dev

joelkuiper12:10:00

again, probably a stupid question ā€¦ but I have a Reagent component like

(defn selectize
  [groups selection settings]
  (let [id
        (util/rand-uuid)
        options
        (vec @groups)
        get-selectize
        (fn [] (.-selectize (aget (js/$ (str "#" id)) 0)))
        selectize!
        (fn [this]
          (let [node (reagent/dom-node this)
                html (str "<input id=" id " name=\"groups\"></input>")]
            (set! (.-innerHTML node) html)
            (.selectize
             (js/$ (str "#" id))
             (clj->js (assoc settings :options options)))
            (.setValue (get-selectize) @selection)))]
    (reagent/create-class
     {:component-did-mount selectize!
      :component-did-update selectize!
      :component-will-unmount #(.destroy (get-selectize))
      :reagent-render
      (fn []
        (deref groups)
        [:div])})))
where groups is an reagent atom that gets initialized via Ajax. The component gets called with
(let [annotation-types (cursor app-state [base-state :annotation-types])]
    (get-semantic-types! annotation-types) ; AJAX get and reset the atom 
    (fn []
      [selectize
       annotation-types
       (atom [])
       {:delimiter ","
        :persist false
        :labelField "name"
        :valueField "id"
        :onChange (fn [e] (.log js/console e))}]))
but on the initial render/update options is null what am I doing wrong here

joelkuiper12:10:02

the value is actually set (verified with the the deref)

joelkuiper12:10:18

hmm inlining the options fixes it

andrea.crotti14:10:46

how do you guys debug something like this?

andrea.crotti14:10:47

football.server> Compiling "resources/public/js/app.js" from ["src/cljs" "env/dev/cljs"]... Compiling "resources/public/js/app.js" failed. clojure.lang.ExceptionInfo: failed compiling file:env/dev/cljs/football/main.cljs at clojure.core$ex_info.invoke (core.clj:4593) cljs.compiler$compile_file$fn__4652.invoke (compiler.cljc:1344) cljs.compiler$compile_file.invoke (compiler.cljc:1306) cljs.compiler$compile_root.invoke (compiler.cljc:1381) cljs.closure$compile_dir.invoke (closure.clj:438) cljs.closure$eval5096$fn__5097.invoke (closure.clj:478) cljs.closure$eval5048$fn__5049$G__5039__5056.invoke (closure.clj:383) cljs.closure$eval5109$fn__5110.invoke (closure.clj:492) cljs.closure$eval5048$fn__5049$G__5039__5056.invoke (closure.clj:383) clojurescript_build.core.CompilableSourcePaths/fn (core.clj:20) clojure.lang.PersistentVector.reduce (PersistentVector.java:333) clojure.core$reduce.invoke (core.clj:6518) clojurescript_build.core.CompilableSourcePaths._compile (core.clj:19) cljs.closure$build.invoke (closure.clj:1674) clojurescript_build.core$build_source_paths_STAR_.invoke (core.clj:160) figwheel_sidecar.auto_builder$default_build_options$fn__16255.invoke (auto_builder.clj:61) figwheel_sidecar.auto_builder$insert_figwheel_connect_script$fn__16301.invoke (auto_builder.clj:201) figwheel_sidecar.auto_builder$warning$fn__16252.invoke (auto_builder.clj:57) clojurescript_build.auto$time_build$fn__16059.invoke (auto.clj:56) clojurescript_build.auto$after$fn__16065.invoke (auto.clj:65) clojurescript_build.auto$after$fn__16065.invoke (auto.clj:65) clojurescript_build.auto$error$fn__16068.invoke (auto.clj:72) clojurescript_build.auto$before$fn__16062.invoke (auto.clj:61) clojurescript_build.auto$make_conditional_builder$fn__16080.invoke (auto.clj:104) clojure.core$mapv$fn__6727.invoke (core.clj:6616) clojure.lang.PersistentVector.reduce (PersistentVector.java:333) clojure.core$reduce.invoke (core.clj:6518) clojure.core$mapv.invoke (core.clj:6616) clojurescript_build.auto$autobuild_STAR_$fn__16162$state_machine__13470__auto____16163$fn__16168.invoke (auto.clj:187) clojurescript_build.auto$autobuild_STAR_$fn__16162$state_machine__13470__auto____16163.invoke (auto.clj:178)

andrea.crotti14:10:34

no clue where to look really given this stracktrace

akiva14:10:06

Step 1: Cry a little...

thheller14:10:41

@andrea.crotti: you give https://github.com/thheller/shadow-build a shot, I'm fairly confident the error message will be more useful

spinningtopsofdoom14:10:05

I'd try cleaning the cache first. (e.g. lein clean or rm -rf resources/public/js/ )

thheller14:10:37

absolutely shameless plug of course šŸ˜‰

dnolen14:10:04

@andrea.crotti: that doesnā€™t look like a complete trace to me - please put that in a pasting service

upgradingdave15:10:27

hey all - anyone using closure goog.ui.Component objects with react? Iā€™m interested in learning if/how goog.ui.Component lifecycle methods could possibly map to react lifecycle and be managed by react? Wondering if the two could work together? Or is it better to choose to go with one or the other (goog.ui.Component vs react component)?

dviramontes15:10:43

Hello! any example tutorials of how to setup a clojure / clojurescript in the same Leiningen project ? ~ Full stack clojure i found this: http://www.clojured.com/ but not sure how relevant it is / isn't ... Thanks!

dnolen15:10:21

upgradingdave: I suspect bridging life cycles automatically will be more effort than it is worth. But I donā€™t see any issues with putting goog.ui components into React components

dnolen15:10:58

@dviramontes: there isnā€™t a canonical way to do that since it depends heavily on what tooling you want to use.

dnolen15:10:12

it can be as simple as ā€œinclude ClojureScript"

dnolen15:10:52

or it can be sophisticated if you want Cider + Figwheel integration etc.

dnolen15:10:42

@dviramontes: what environment do you want to use Emacs/Vim/Cursive/SublimeText ?

dnolen15:10:01

@bhauman: which reminds me, Figwheel docs on how to use Component to start Figwheel + Ring together would be useful.

dviramontes15:10:57

@dnolen: currently im on intellij with cursive

dnolen15:10:25

the sooner all important ClojureScript tooling moves towards accurate instructions on how to use these things as libraries, the better.

dnolen15:10:55

@dviramontes: then I would just stick with ā€œinclude ClojureScriptā€, you donā€™t need anything else with that setup.

dnolen15:10:07

add the Ring or Pedestal bits to taste

dnolen15:10:41

@dviramontes: Figwheel also works well with this setup but the docs for newcomers is lacking

bhauman15:10:52

@dnolen right there with you

dviramontes15:10:50

@dnolen: awesome, thanks again!

upgradingdave16:10:09

nice to know that goog.ui components can work inside react and that Iā€™m not crazy for going down that route, thanks @dnolen

dnolen16:10:34

@upgradingdave: that one of the big value props of React life cycle you can control mutative components without too much difficulty

upgradingdave16:10:22

very cool, Iā€™ve only used the react closurescript wrappers, I need to read more about react api to understand how the virtual dom actually works, such interesting stuff, thanks again

bhauman16:10:35

@andrea.crotti: be sure to check the figwheel server log

will_norman18:10:06

I'm attempting to upgrade from 1.6 to 1.7, but running into an exception when I compile:

will_norman18:10:18

Compiling "resources/public/generated/client.js" failed.
java.lang.IllegalStateException: Can't dynamically bind non-dynamic var: clojure.tools.reader/resolve-symbol

will_norman18:10:38

I've updated relevant libraries to be at latest stable, which leads me to believe it's something in our code

will_norman18:10:54

has anyone run into this issue before, and hints in things to look for?

will_norman18:10:26

this occurs when running lein cljsbuild once

dnolen18:10:37

@will_norman: sounds like you have tools.reader conflict in your dependency graph

dnolen18:10:44

lein deps :tree should make it clear

will_norman18:10:55

cool, will check that out

will_norman18:10:27

interesting looks like there are several versions, is there one I should prefer? Looks like clojurescript is bringing in [org.clojure/tools.reader "0.10.0-alpha3"] which seems to be the newest version, so I assume that one?

will_norman18:10:43

[org.clojure/tools.reader "0.8.10"] is the latest non-alpha

dnolen18:10:32

@will_norman: ignore anything but the one that ClojureScript wants

will_norman18:10:47

awesome, will do, thanks again

jstew20:10:08

Possibly more of a browser support/js question: Let's say I have a vector full of strings. Is there a way to download those as CSV client side, or do I have to pass through the server? I want it to be reliable.

dnolen20:10:33

@jstew: can you clarify a bit more? Not entirely clear what you are asking.

jstew20:10:18

I have a list of strings that I would like to join on \n, then use the browser to download them. Like you would with a normal request response cycle with content-disposition attachment, but client side instead with clojurescript.

jstew21:10:27

@bostonaholic: Thanks! That's amazing simple_smile

jstew21:10:06

That solves half of my problem

bostonaholic21:10:51

then you can use it to "download" the csv file like so:

[a {:href (str "data:text/csv;charset=utf-8," (js/encodeURIComponent (csv/write-csv csv)))}]

jstew21:10:51

And that should solve the other half. That's going to simply display the data rather than present it as a file download though. That may be good enough for what I'm up to.

bostonaholic21:10:02

yeah, my use cases have been a table of data with a "Download as CSV" link. I hold the table data as an atom and pass that to write-csv

jstew21:10:24

That's exactly what I'm doing with reagent.

bostonaholic21:10:36

heh, also using reagent šŸ˜œ

statonjr21:10:28

Chrome automatically downloads a CSV file.

sandbags21:10:56

Having an issue with porting some CLJ code to CLJS, have the problem down to one line and about whether a function name is fully qualified or not, the code works on in CLJ-land. Any ideas why itā€™s different in CLJS? https://gist.github.com/mmower/c73f1d93528323717217

nberger21:10:37

@sandbags: perhaps related to http://dev.clojure.org/jira/browse/CLJS-240? Doesn't give much info but the description looks like a match. Does the warning appear with all :optimizations levels?

sandbags21:10:30

nberger: iā€™m not sure what that issue actually is as there seems to be no body when I look at it..?

sandbags21:10:02

i am assuming that i am at 0 optimisation

sandbags21:10:07

since i am in dev mode

sandbags21:10:25

and have :optimizations :none in the project.clj

dnolen21:10:58

@sandbags: thereā€™s already a ticket for this issue

dnolen21:10:05

in the meantime donā€™t qualify your protocol methods

sandbags21:10:26

dnolen: ok, thx

sandbags21:10:33

dnolen: CLJS-1451?

sandbags21:10:38

mfikes: right, thx

sandbags21:10:13

easy to find the ticket once i have the form of words around qualified method names simple_smile

dnolen22:10:00

wow achievement unlocked, first time I ever had a use case for zippers in a library simple_smile