Clojurians
#clojurescript
<
2016-04-08
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

bpicolo02:04:17

what's the right way to ignore cljs-devtools for an advanced-mod prod build

bpicolo02:04:21

id est (devtools/install!)

bpicolo02:04:58

I guess I could have a different entrypoint for dev but seems weird

bpicolo03:04:18

(if ^boolean js/goog.DEBUG (devtools/install!))

bpicolo03:04:21

found my answer

richiardiandrea03:04:44

@bpicolo: interesting, have you noticed performance issues?

bpicolo03:04:30

richiardiandrea: nope, just don't want dev artifacts in a production build

danielcompton03:04:18

@bpicolo: we have three src folders, src, dev-src, prod-src. Dev tools only gets required in dev-src.

richiardiandrea04:04:43

@bpicolo: agree I was just curious :)

grounded_sage05:04:31

I'd like to develop a client side only SPA that is pre rendered for download speed and user experience. Wondering what option would be best Om or Reagent.

rmuslimov07:04:32

@grounded_sage: this is like car-choosing process? what you prefer honda or toyota? reagent is easier to start, btw, so may be critical if it really first app using clojure.

grounded_sage07:04:35

@rmuslimov: I've built a few different static sites using a few libs. Currently venturing into the CLJS side of things a bit more. Been contributing to Braid chat which uses Om Now. Just wondering what would be better. Primarily for server side rendering story and handling the data. Not afraid of a little slow to get started (investing in learning) if it pays off.

plexus07:04:43

@grounded_sage: apart from the cosmetic difference the main differentiator is how they manage state. Read up on om cursors and reagent atoms and om next transactor and take your pick

plexus07:04:53

For getting off the ground quickly though reagent is a good choice

rmuslimov07:04:59

however om.cursor and om.next is opposite right? is that true that om.next is best for new projects, or people still consider using previous Om?

grounded_sage08:04:14

@plexus: cheers. I am leaning more towards Reagent at present. Despite being very interested in Om Next.

dm308:04:59

don't forget about Hoplon if you're looking for something simpler

grounded_sage08:04:42

I'm betting on React so focusing my efforts towards using something that uses it. I'd go straight for Om Next if it wasn't for such a huge divide in the community with heaps saying Reagent is better.

octo22108:04:08

I dunno...I'm using Om.prev and considering whether to upgrade to Om.next or switch to Reagent...Om.next looks heavy but I'm not sure I like Reagent's pattern of distributing state over many atoms, and I don't like seeing derefs in functions

grav08:04:47

@octo221: you can start out with one global state atom in Reagent. We did that. Currently we have a few components that maintain their own state atom, usually when they maintain some transient state, or when they wrap a stateful JS-component (like Openlayers).

grav08:04:23

We went from Om.prev to Reagent, and the whole team really like the data-first approach.

pesterhazy09:04:03

Is there a cljs function akin to clojure.core/format that allows for specifying positions, like (format "%2$s %1$s" a b)?

pesterhazy09:04:22

goog.string/format doesn't seem to include this functionality

octo22109:04:46

@grav: my app has global undo (not through Om, just using a normal vector to store states), how easy is it to get global undo with Reagent ?

grav09:04:18

@octo221: it should be just a matter of reset’ing the global state atom.

octo22109:04:43

and all the child atoms will be updated accordingly ?

octo22109:04:28

and do the states of child atoms derive from that of the parent always ?

roman01la10:04:26

Are there any known issues with cjs/es6 modules used as foreign libs? Doesn’t seem to work for me :disappointed:

odinodin10:04:00

anyone got React.addons.TransitionGroup working with Reagent (not the CSSTransitionGroup) ?

mrg11:04:23

Has anyone managed to get a remote clojurescript browser repl to run when developing in cordova/mobile?

roman01la12:04:31

It looks like it’s not possible to require a function from cjs/es6 module if that function is a default export. Meaning that the namespace becomes a function itself. Is there a way around? I could re-export default export as named export from another module, but maybe there’s a better way.

dnolen15:04:28

@roman01la: seems like a generic question about ES6 module support, probably something you can ask on the Closure mailing list if you don’t get an answer here

roman01la16:04:27

@dnolen: Sorry, I don’t think it’s a problem of GCC. The problem that I described is more about CommonJS modules and it seems like there’s no really way around it. Because that’s how CJS exports work. But there’s a weird thing is going on with ES6 default exports. Let’s say I have the following ES6 module:

function a() { return 1;}
export default a;
When compiled, a value of var a will be assigned to default property of a namespace object. But when I try to require that namespace in ClojureScript and call default var from it (`(lib/default)`), in compiled JS output it looks something like this: module$lib$default$.call(). Notice that a symbol $ was appended to default, but it should be just default, because that’s where the var is assigned.

roman01la16:04:32

Not sure I’m explaining this well...

dnolen16:04:21

@roman01la: oh hrm this may be something we want to tweak in munging then

dnolen16:04:33

currently we munge based on ECMA-262, we should probably respect the language settings

dnolen16:04:40

patch welcome for something like this of course

dnolen16:04:49

currently default will always be munged to default$

jamieorc16:04:20

@jonathandale: nice to see you on a cljs thread!

jonathandale16:04:34

@jamieorc Yep, almost finished a side-project in re-frame, and started to work on a cljs project at work. Enjoying it.

base69817:04:02

I have a single function which doesn't use any clojure specific stuff. How would I build a js lib out of it, so I can call it in js? It's in a clojure backend, but I need to use it for another project in the front end

base69817:04:10

what's the clojure way of doing that?

base69817:04:26

copying it into it's own directory seems flakey

base69817:04:10

"copying and keeping a cljs/clj version separately"

darwin18:04:07

@base698: I don’t quite understand how exporting clojurescript function to be visible from javascript can potentially have anything to do with words “clojure”, “backend” and “own directory”. If you have clojurescript function and you want it to be visible from javascript under :advanced optimzations use ^:export metadata to tell compiler to preserve its name

ronald18:04:52

@base698: like js interops?

base69818:04:35

I have a clojure function, it's in a clojure project. the algorithm in said clojure function needs to be run from javascript, so i need to have some way to take just that one function, compile it to JS and run it from another app

base69818:04:50

so options are: make a cljs build separately, with another dir structure and when I run that copy just the one function into it, do the build, import that build from another project

base69818:04:58

right now I ship the clojure jar to artifactory, i'd make a separate deploy job that shipped the js somewhere else

ronald18:04:20

yes the cljs build sounds like the way i have seen people do it before.

darwin18:04:08

then you have three tasks at hand: 1) turn that clojure function into clojurescript function (even if it means just renaming the file extension from .clj to .cljs) 2) compile clojurescript project using your favorite tooling and produce javascript file(s) 3) make sure that selected clojurescript functions are exported as javascript API

base69818:04:28

Yeah, sounds right

base69818:04:58

How do you make your own lein tasks, to do things like rename a file etc?

darwin18:04:49

I’m afraid it is not a good idea to use lein task for generating source files

darwin18:04:18

what about a sym-link? or use clojure macro to generate clojurescript code (advanced)

base69818:04:36

the macro idea could work.

base69818:04:41

maybe symlink too

base69818:04:44

will have to try that

darwin18:04:55

or use cljc extension, that is the best way I think

darwin18:04:33

this will open a possibility to write platform-dependent parts using reader conditional (if ever needed in the future)

fabrao19:04:52

hello all, what is the diff from '(defn contact [c] [:li [:span (display-name c)] [:button {:on-click #(remove-contact! c)} "Delete"]])' and '(defn contact [c] [:li [:span (display-name c)] [:button {:on-click (remove-contact! c)} "Delete"]])' What is the use of #?

shofetim19:04:18

The hash # creates another function. The first version means function () { remove-contact! c} and the second means run remove-contact! c now.

shofetim19:04:26

you likely meant the first

jr19:04:09

You can see the difference when the code is expanded

user=> (macroexpand-1 '#(remove-contact! c))
(fn* [] (remove-contact! c))
user=> (macroexpand-1 '(remove-contact! c))
(remove-contact! c)

lwhorton20:04:52

Has anyone come up with a way to provide a convenient console.log fn? I have this…

(defn log [& args]
  (.log js/console (clj->js args)))
But it has the downside of not mapping properly to the invoker, so I can’t inspect the source and find who is doing the logging.

lwhorton20:04:27

(i.e. every call to log looks like its coming from utils.core line:5)

roman01la20:04:09

@lwhorton: I guess a macro could help here

roman01la21:04:30

@dnolen: Regarding CLJS-1620, can you give any context on where to start? I’m pretty new to ClojureScript compiler. I guess :module-type information could be used to control munging.

jr21:04:21

@lwhorton: does setting *print-fn* to log and using println help?

cmcfarlen21:04:58

@base698: I'm not certain I understand, but it sounds like you are talking about cljc. If you have a namespace in a cljc file, both clojure and clojurescript can require it. You can use the conditional reader to add code specific to the target language.

base69821:04:39

that sounds exactly what I need, where is that at?

cmcfarlen21:04:01

sorry, I wrote that up before reading all the way down. ha. @darwin and others also recommend this approach.

base69821:04:14

Pretty cool. Exactly what I needed.