Fork me on GitHub
#clojurescript
<
2015-11-08
>
jindrichm11:11:29

I use lein-npm to manage npm dependencies. But how do I actually require them? Do I need to use :foreign-libs?

lukemorton12:11:47

I want to pass around references to functions, i.e. their name as a symbol and dynamically call that function later. Is this possible in clojurescript?

lukemorton12:11:36

I’m storing this function in my application state at the moment and would prefer to store something more readable and debuggable

cjmurphy12:11:58

@lukemorton: Functions can be stored in a hash-map atom and referred to by a key that is a :keyword. But to me it sounds like you are already doing that when you say 'I’m storing this function in my application state'.

lukemorton12:11:26

Yeah thats what Im doing, just looks like garbage when I print it out to console

cjmurphy12:11:10

Yes it can be hard to debug. When I see them printed out to the console the only guidance it is giving me is that I've done it wrong. It doesn't really show how I've done it wrong. Sorry can't help much more...

lukemorton12:11:18

Hey no problem simple_smile Just thought it might be possible to pass around a symbol reference to the namespace of the function but guess after advanced compilation this isn’t possible.

dnolen12:11:45

@lukemorton: yeah that isn’t possible

dnolen12:11:21

@jindrichm: the answer depends on whether you are targeting the browser or Node.js

jindrichm12:11:45

@dnolen: I'm targeting the browser.

dnolen14:11:04

@jindrichm: it will be very challenging to use :foreign-libs for individual npm deps I think. Probably easier to build a single file of your npm deps (using Webpack or whatever) and just make a single :foreign-lib entry for that.

jindrichm14:11:40

@dnolen: Thanks, I'll try that. I've already stumbled upon Webpack in this context (https://groups.google.com/forum/#!topic/clojurescript/6GQLHAOWpZc).

Drew Verlee22:11:28

does anyone know a resource that gives a good comparison between elm and clojurescript and the direction both are headed. I know that's asking a lot.

Drew Verlee22:11:51

the answer might be to "read up on both of them" simple_smile