Fork me on GitHub
#clojurescript
<
2015-11-04
>
tony.kay00:11:07

can anyone tell me where to find how to make figwheel use wss instead of ws?

tony.kay00:11:05

ah, found it...nvm

mikera01:11:03

Is there a good example of a full project that builds properly for both Clojure and ClojureScript (including tests!) with cljc?

mikera01:11:37

Looking for a template to guide a bit of cljc porting for core.matrix

taylor.sando01:11:08

Datascript builds for both

dnolen01:11:50

will be cutting a new release on Friday, if people know how to test their projects with master - do it

dnolen01:11:10

actually just going to cut a pre-release simple_smile

dnolen01:11:21

actually just try the prelease should hit Maven shortly

mikera02:11:04

Thanks @taylor.sando . Do you know if it is possible to get Maven to run both Clojure and ClojureScript test suite at once?

taylor.sando02:11:47

I don't really know that much about Maven.

richiardiandrea02:11:31

in reagent, when the call to the atom is included in a function...it does not do its magic right?

dnolen02:11:57

@mikera pretty sure you would need the clojure maven plugin to support that

mikera02:11:30

Thanks @dnolen I will take a look.

mikethompson02:11:26

@richiardiandrea: the rule is a simple one: if, during the execution of the render function, an r/atom is derefed, then that ratom will be considered an input signal.

richiardiandrea02:11:03

yes, it was another problem (frustration, as usual simple_smile )

richiardiandrea02:11:13

tnx for the answer

mrg12:11:59

Any idea why this would give a "goog is undefined" error? Shouldn't :optimizations :advanced take care of that?

mrg12:11:04

:prod {:builds {:app {:source-paths ["env/prod/cljs" "src/cljs" "src/cljc"]
                                   :compiler {:optimizations :advanced
                                              :pretty-print false
                                              :output-to     "resources/public/js/app.js"
                                              :output-dir    "resources/public/js/out"
                                              :asset-path   "js/out"}}}}

dnolen12:11:02

@mrg: you haven’t shown what markup you are using.

mrg12:11:02

@dnolen: What markup?

dnolen12:11:42

@mrg: if this is running in a browser you must have supplied some markup no?

dnolen12:11:58

if you’re running in Node.js you shouldn’t be using :advanced

mrg12:11:16

I'm running in the browser

mrg12:11:28

and am including it via <script src="js/app.js" type="text/javascript"></script> if that's what you mean?

mrg13:11:31

It seems to be that I messed up my project.clj. If I'm modifying the top-level :cljsbuild then it compiles

mrg13:11:41

Now I am getting different errors at least simple_smile

dnolen13:11:03

ok that markup looks fine

mrg13:11:56

It's something with my leiningen profile @dnolen . I'll try to see what is going wrong there. Thanks for your help

lvh14:11:27

dnolen: Why shouldn’t one use Node.js + :advanced?

dnolen14:11:29

Because it doesn't solve any problems and we don't really support it

dnolen14:11:03

advanced is only for web clients

rohit14:11:32

@lvh: [some experience report with node.js + :advanced] i have been using it in my electron app. I provide the necessary node.js externs. the only real reason over :static-fns is code obfuscation. I know its a pretty weak reason.

dnolen14:11:58

Yeah the problem is that ClojureScript code is far too regular for it to be a good obfuscation strategy

bojanx10014:11:16

Hi guys. Does anyone know if I can get an element and change style (width for example) on it from clojurescript? Thank you.

rohit14:11:00

@dnolen: I can believe that.

dnolen14:11:34

in the old days before :pseudo-names and :source-map I would debug advanced build issues via pretty-printing only

rohit14:11:38

@bojanx100: you can use (.getElementById js/document “app”) to get a dom element with id app.

dnolen14:11:32

@bojanx100: you can use browser JavaScript APIs for this. Lean on Google Closure if you want to protect yourself from browser quirks

rohit14:11:37

@bojanx100: I’ve found this to be pretty good resource about learning about JS<->CLJS interop. https://kanaka.github.io/clojurescript/web/synonym.html

bojanx10015:11:17

i did it with this (set! (.-width (.-style (.getElementById js/document "side"))) "0%") , @rohit: @dnolen: thanks!!!

rohit15:11:18

@bojanx100: I think you can clean it up now with using goog.style and goog.dom. https://closure-library.googlecode.com/git-history/docs/namespace_goog_style.html

bojanx10015:11:06

@rohit: great. I'll give it a look, thanks!

puppybits16:11:14

Hey if I'm reducing a vector of maps is there a way to affect other maps in the vector? In javascripts reduce I always return the entire array with modifications from each run of the function. I'm assuming the right way in clojure is that the reduce returns all the modifications and then I assoc-in as a secondary step. Is that right?

thheller16:11:50

@puppybits: you can update directly in a vector (update-in [{:a 1}] [0 :a] inc) => [{:a 2}], can do that in reduce too

puppybits16:11:33

@thheller: ok so I map over my mutations and update-in to all the places in the vector that need to be changed. That make sense. Thanks.

joelkuiper18:11:08

So at Reactive 2015 there was a demo of http://cycle.js.org/, I was wondering if it would be a crazy idea to write that in maybe < 100 lines of code using Aleph (or core.async and transducers) + Hiccup + virtual-dom

richiardiandrea19:11:35

A colleague of mine just wrote (without offending anyone here please) "A fully reactive JavaScript framework for Human-Computer Interaction" -> "The first web framework written by marketing specialist"

bhauman19:11:13

and he was joking??

richiardiandrea19:11:58

not sure , if you can write it in 100 lines of Clojure maybe it really is just marketing 😄

dnolen19:11:40

cycle.js does look interesting, but it doesn’t seem like much more than wiring up core.async to a VDOM thing

richiardiandrea19:11:20

I guess this was my colleague's and @joelkuiper's point

dnolen19:11:27

fwiw I think core.async + React / Figwheel has shown that mutable observation is a big tradeoff

dnolen19:11:58

and not one that can be made lightly

richiardiandrea19:11:30

yes I see it as the (better) alternative to RxJS

dnolen19:11:05

not sure on what axis you mean “better”. RxJS + VDOM seems to fit the same bill.

richiardiandrea19:11:21

Sorry David, I say better probably because I am biased towards the language core.async/React/Figwheel are using simple_smile but yes I totally agree it is the same thing they are trying to accomplish, using the same machinery..as well (VDOM and being reactive).

micahasmith20:11:16

any advice on how to do a clojurescript build for a release/deploy? in live should it still be loading N scripts from goog/?

nullptr20:11:58

micahasmith: no — the build process will combine all the goog/… assets in non-:none optimizations (advanced being best)

nullptr20:11:16

loading goog/… stuff live would be very slow

micahasmith20:11:34

do you know off hand what flag[s] i need to trigger that build style?

micahasmith20:11:47

{:id            "dev"
                        :source-paths  ["src/analyticsjs"]
                        :figwheel      false
                        :clean-targets ^{:protect false} ["resources/public/js/compiled" "target"]
                        :compiler      {:main       "analyticsjs.core"
                                        :asset-path "/js"
                                        :output-to  "resources/public/js/cljs.js"
                                        :output-dir "resources/public/js"}}
                       ]

micahasmith20:11:07

i think this was what i was missing.

dnolen20:11:15

@micahasmith: you’ll want to specify a production build and add :optimizations :advanced to :compiler

micahasmith20:11:16

trying out :optimizations :advanced now

dnolen20:11:33

note that I would test this locally first

micahasmith20:11:33

thx guys. i swear i searched all over the web for this 😉

dnolen20:11:44

if you haven’t done a lot of ClojureScript dev you may have some issues to sort out

micahasmith20:11:02

this is my first ever cljs proj that im releasing

dnolen20:11:26

as a rule of thumb do not wait to try advanced builds

nullptr20:11:27

the issues are likely to be non-existent or minor unless you have external data/JS deps — those can be complicated

dnolen20:11:30

do them early and often

dnolen20:11:55

but especially when you add a new dependency to your project

micahasmith20:11:04

i didnt use the cljs externs/deps route for my external stuff, i just did js/

dnolen20:11:05

or call out to some HTML 5 JS api

dnolen20:11:23

@micahasmith: right that’s going to be a problem

nullptr20:11:27

micahasmith: would be curious what kind of stuff you were searching/googling for that didn’t come up — i could see a case for a wiki page or something about “putting cljs into production"

dnolen20:11:53

@micahasmith: if it’s a standard HTML5 you’re probably covered

nullptr20:11:57

micahasmith: looks like you’ve earned yourself a trip to the https://github.com/clojure/clojurescript/wiki/Dependencies page!

dnolen20:11:01

but if you’re calling into 3rd party libs - will not work

micahasmith20:11:23

well at least i got to hear what my problem is before i experienced it

dnolen20:11:30

and I wouldn’t bother with Googling

dnolen20:11:36

the wiki is the source of truth

dnolen20:11:30

that and Google Closure documentation

micahasmith20:11:27

@nullptr my searches were lein figwheel deploy lein cljsbuild deploy lein cljsbuild clean clojurescript deploy

micahasmith20:11:17

i was looking for some wiki article or blog article that spoke directly to it. the cljs wiki that has the production deploy section at the end of it,,, shouldve saw it in my skimming

micahasmith20:11:54

ok thanks for your help @dnolen and @nullptr going to jump into getting this fixed

nullptr20:11:55

that is helpful, at present we use optimize/min/advanced/production in different areas, and would be helpful to make the language more consistent here

mrg20:11:45

To be fair, the figwheel leiningen template ought to include a setting to just compile clojurescript for production, instead of just packaging everything up into a jar

pshk4r20:11:50

I am looking for how to share bidirectional routes (silk) between frontend (Reagent) and backend. Could somebody point me to the right direction, please?

mrg20:11:05

I had that very same issue this morning

domkm20:11:10

@pshk4r: If you're using Clojure 1.7, I'd suggest reader conditionals (using .cljc files).

domkm20:11:39

< 1.7 you'll need to use CLJX or duplicate the code.

pshk4r20:11:53

@domkm: thank you, I actually use 1.7, will learn about .cljc now P.S. thanks a lot for the great library simple_smile

domkm20:11:22

Great simple_smile You're quite welcome.

richiardiandrea20:11:34

Guys, any tool in ClojureScript, Cljsjs or JS to strip Markdown formatting? Similarly to https://github.com/theJohnnyBrown/endophile ?

joelkuiper22:11:28

@richiardiandrea: is it on Github 😛 ? I might star it because it’s basically the same idea I had 😉 you loose a lot of the benefits of using shouldComponent update with immutable data structures, which I guess is the big caveat

micahasmith22:11:54

@dnolen @nullptr— does this look like an acceptable way to import externs?

(ns analyticsjs.libs
  (:require [goog.object :as object])
  )

(def google (object/get js/window "google"))
(def jquery (object/get js/window "jQuery”))

joelkuiper22:11:00

@richiardiandrea: you could bolt that on with some meta-data or flag when passing around the values in the core.async channels , but you’d basically end up with something like React

dnolen22:11:09

@micahasmith: I would not do that

dnolen22:11:27

if you need jQuery use the cljsjs one

joelkuiper22:11:45

@richiardiandrea: although maybe it’s a more light weight solution, but you’d tie yourself into the Aleph/core.async infrastructure … but that might have the benefit of spitting out a nice flow diagram using some macro or somesuch

dnolen22:11:53

I don’t think you need to do anything special for Google Analytics but I don’t remember (if that’s what you’re trying to do)

micahasmith22:11:03

i’m using google.visualizations

micahasmith22:11:22

k. jumping into cljsjs docs

joelkuiper22:11:53

@richiardiandrea: I actually like the idea in concept (core.async, pure functions, Hiccup markup and just a simple virtual-dom diff+patch), but if you take into account the edge cases and the plumbing needed to make it an elegant solution with the updates etc, I guess you’d end up with something similar to React itself.