Fork me on GitHub
#clojurescript
<
2015-12-08
>
jaredly01:12:25

Do macros not work w/ figwheel REPL? getting weird errors

jaredly01:12:15

They seem to work fine when required from e.g. core.async, but my user-defined macros aren't working right

richiardiandrea01:12:04

@jaredly: are your macros defined in a .clj file?

jaredly01:12:18

just in-line w/ the other cljs

richiardiandrea01:12:27

that's not going to work

richiardiandrea01:12:45

almost sure about it

richiardiandrea01:12:08

but @dnolen is replying so I yield

dnolen01:12:17

Yes ClojureScript are not like Clojure macros

dnolen01:12:28

This is pretty well documented

jaredly01:12:46

I wasn't sure if they'd been brought up to speed -- there weren't any errors

dnolen01:12:04

It's also why ClojureScript starts at 20k gzipped and not 300k gzipped

dnolen01:12:12

It's never going to change

jaredly01:12:10

is there any use in keeping defmacro around in cljs then? it's a big red herring

dnolen01:12:59

It doesn't exist really - but a minor bug that it doesn't error out. As usual patches most welcome!

richiardiandrea01:12:38

oh did not know that 😉

mfikes01:12:45

@jaredly: When you write macros for bootstrapped ClojureScript, even though they are written in namespaces required from the consuming namespaces, all namespaces are compiled as ClojureScript. Thus defmacro must exist in ClojureScript.

jaredly01:12:27

@mfikes: ah intersting. looks like it's a macro itself 😄

mfikes01:12:47

Perhaps it could be made to error out at the REPL, which is what I think David's suggesting.

jaredly01:12:35

yeah. or if it's in a .cljs file?

txus09:12:52

I’m seeing an error using core.async/map. Here’s a minimal example to reproduce:

d-t-w09:12:27

async/map takes a collection of source channels, not just the one.

d-t-w09:12:35

(async/map inc ch)

d-t-w09:12:42

(async/map inc [ch])

txus09:12:11

oh, the signature is a bit different from clojure.core/map, I expected it to be the same

txus09:12:13

okay then

txus09:12:16

let’s see simple_smile

pepe10:12:32

Hello, I am having problem with externs for google-maps. I use cljsjs package as described here https://github.com/cljsjs/packages/wiki/Using-Packages with both dependency and require in my core namespace. When running lein cljsbuild I am getting No such namespace: cljsjs.google-maps

txus10:12:40

it worked! thanks @d-t-w

pepe10:12:45

What am I doing wrong please?

pepe10:12:28

Without the require in the core, names get mangled and app does not work at all.

pepe10:12:50

So I found the answer. I was using .setLabel on Marker instance which is not in the google-maps cljsjs package. And indeed the require is not needed.

dvcrn10:12:52

Little question. I have a clojurescript project licensed under GPL

dvcrn10:12:23

I'm wondering what would happen if a third party is integrating the compiled cljs binary into a closed source project

dvcrn10:12:46

Does GPL in this case force the project to be open sourced and adopt GPL?

dvcrn10:12:09

Not very good with licenses here.

dm310:12:57

GPL only requires you to provide source to the users

dm310:12:04

regarding integration - I assume you mean a node.js project?

dvcrn10:12:51

it's a editor plugin

dm310:12:13

don't really now how the linking clause applies to this environment, but I'd expect the GPL lib would "poison"/"bless" the rest of the project simple_smile

dvcrn10:12:22

in that case would re-licensing under LGPL change that?

grav12:12:57

Is it possible to have a main entry point a la java? So that I don’t have to bootstrap my app by relying on the side-effects of requiring a namespace?

grav12:12:32

Maybe I should just wrap the app bootstrapping code in a (defn main []) and do <script>myapp.core.main()</script> from the html-file?

martinklepsch12:12:23

@grav: in boot-cljs there is an init-fn thing which is similar to :main

naomarik13:12:49

hello! I'm jacked to clojurescript with cider and trying to eval (println (GET "")) gives me this org.mozilla.javascript.EcmaError: ReferenceError: "XMLHttpRequest" is not defined. (rhino.clj#41)

naomarik13:12:30

it makes the ajax request fine in the browser, but i'm trying to use the repl to explore what it's returning

dnolen13:12:03

@naomarik: all JS environments are different, if the constructor is not actually in the language specification you cannot expect such things to work.

jannis13:12:42

Has anyone here used cljsjs.showdown with a custom extension defined in ClojureScript yet?

jannis13:12:51

It expects a JS function that returns an array of objects, each with a .lang, .regex and .replace member. Those members are a string, a JS regular expressions and a JS function, respectively.

jannis13:12:12

Can I just define all this as if I was writing for ClojureScript and then wrap it in (clj->js my-extension-function) or do I need to do more?

dnolen13:12:32

@jannis in general I do not recommend clj->js

dnolen13:12:48

it’s a convenience but nothing I would ever use for critical interop

dnolen14:12:04

we have JS literal support and JS helpers via Google Closure for a reason

jannis14:12:01

@dnolen: What do you mean by "JS helpers"?

dnolen14:12:25

you have an entire library (Google Closure) for dealing with JS objects and JS arrays

dnolen14:12:38

if you’re dealing with an API just leverage this stuff

dnolen14:12:12

clj->js is just convenience - it performs terribly and has many corner cases

jannis14:12:45

Ok. I'm making a bit of progress by creating JS arrays and objects with #js and passing those to Showdown. Still throwing errors but this time it's about creating JS regexps from other regexps. Should be able to solve that.

jannis14:12:51

Ah. The cljsjs version of Showdown takes a pattern string, not a regexp. Done. Working. Sweet. simple_smile

naomarik19:12:32

@dnolen: what's your opinion on reagent?

dnolen19:12:30

@naomarik: seems cool and a lot of people use it!

dnolen19:12:36

never used it myself so I don’t have an opinion

naomarik19:12:08

i haven't found much in the way of comparison between the two, you have anything to suggest in regards to that?

naomarik19:12:41

btw my experience - i've just picked up clojure 3-4 days ago

naomarik19:12:52

a bit overwhelmed with all the options and terminology

dnolen19:12:55

@naomarik: I would recommend trying both

dnolen19:12:03

Reagent is probably easier to get started with

naomarik19:12:15

yeah i'm playing with reagent atm from luminus

naomarik19:12:55

do most people there at cognitect use emacs or cursive?

dnolen19:12:59

Om Next is now more of a complete UI framework than most other things

naomarik19:12:45

i keep seeing reference to this but no specific Om Next repo

dnolen19:12:46

yes it’s just a new namespaces(s)

cab19:12:17

for your convenience 😉

naomarik19:12:35

thanks 😉

noisesmith19:12:17

I'm trying to figure out how to make the sente post fallback actually run - do I have to do something special in the frontend code?

noisesmith19:12:04

I wrapped the post-fn in a middleware and have verified that even with the get handler that sets up the websocket malfunctioning, the post handler isn't getting hit

pandeiro19:12:07

is there a blog post or tutorial for getting started with closure modules from a cljs perspective?

jaen19:12:20

@noisesmith: I think you can choose what you want to connect on

jaen19:12:48

:type keyword in options

noisesmith19:12:05

@jaen: so this means I need to do the fallback manually from my cljs?

jaen19:12:23

Not exactly, it means you have to fallback manually if you want to test it.

jaen19:12:37

It will fallback automatically if browser doesn't support or can't connect through WS

noisesmith19:12:10

I'm already using :type :auto

noisesmith19:12:47

and I modified my ws handler to fail, the post endpoint isn't even getting hit

leov21:12:51

um. sorry if the question is not very smart, but what is the newest example on how to use figwheel and connect from vim to browser page via nrepl? (I use vim-fireplace)

leov21:12:29

I tried to do om.next tutorial, and picked figwheel (now it's figwheel-sidecar) from there, and it's obviously connected to browser page

naomarik21:12:34

i'm currently stuck trying to do this with cider/emacs

leov21:12:26

I'm not sure what exactly does piggieback do, and what austin/weasel do

noisesmith21:12:26

I just use figwheel in a regular terminal window, since it is mostly there for the hot-reloads anyway

leov21:12:49

one year ago I managed to do setup correctly, but I just picked chestnut example

leov21:12:50

problem is - I see that figwheel is definitely talking to browser page window

leov21:12:59

because of js/alert being available

leov22:12:30

when I install nrepl-port option into figwheel-sidecar config, it starts nrepl (as written on figwheel window)

leov22:12:44

but when my vim-fireplace connects there, it launches well rhino environment

leov22:12:15

I totally don't get it on how many moving parts are there and what would be the fresh example..