Fork me on GitHub
#clojurescript
<
2015-06-12
>
shriphani00:06:37

Hi. I’m trying to use cljs for a new project. It looks like a proper kludge to set up. I have a repl running at port 9000, done that repl/connect bit in my code and I can’t do anything in the browser console. what gives ?

shriphani00:06:55

actually nvm I got confused - the repl uses the browser instance. is there any way to make cljs do its thing in the chrome console ?

esdee00:06:12

@shriphani: try

(enable-console-print!)
after that
(println “Hello”)
should appear in the browser console.

shriphani00:06:39

no I see that

shriphani00:06:44

I want to type cljs in the console

shriphani00:06:02

I am just typing it in my code

shriphani00:06:09

and having it print in the console

shriphani00:06:26

a bit shit but what in life isn’t ?

bostonaholic00:06:23

@shriphani: your browser console cannot understand cljs

shriphani00:06:49

well I imagined there would be a new repl or something that I could type cljs into

shriphani00:06:53

nvm. brainfart.

bostonaholic00:06:16

that's what your repl is for in your terminal

bostonaholic00:06:48

the same way you can't type coffeescript into the browser console

cmdrdats08:06:11

what kind of gotcha’s is there to using advanced compilation? I’m using the google closure autocomplete, which is working in simple optimization mode, but not advanced

cmdrdats08:06:19

nope, just not working

cmdrdats08:06:33

My #1 suspect at the moment is that I’m calling (cljs.reader/read-string) to pull the data from an html attribute (to get the list of stuff to autocomplete)

cmdrdats08:06:04

actually, on my dev environment, I get a "function not found"

cmdrdats08:06:32

(obviously with some a.Xd.f compressed name)

cmdrdats08:06:49

I call setup on the body node of the document on window load, from a separate namespace

andrewmcveigh08:06:16

cmdrdats: interop calls can be compressed when they shouldn’t be in advance compilation.

andrewmcveigh08:06:52

stuff like (.log js/console …), if you don’t have the correct externs

cmdrdats08:06:47

odd - including (.-value entry) ?

jrychter08:06:38

Does anybody know of client-side "routing" solutions that do not have an impedance mismatch with React? Something that would let me bind my component hierarchy to an URL scheme.

andrewmcveigh08:06:45

cmdrdats: Not sure about those. I don’t recall ever having a problem with properties tbh.

zoldar09:06:38

@jrychter: I asked you about it on twitter but I think I didn't fully get your explanation - do you mean tight coupling routing with components? as in passing a parsed decomposed url down to every component and letting it interpret it accordingly?

jrychter09:06:00

@zoldar: Yes, kind of. I want my component tree coupled to URL tokens. I'd like to be able to declare in every component how many URL tokens it consumes. That way you get composability: plug a component into your tree anywhere, and URL navigation just works.

cmdrdats09:06:58

@andrewmcveigh: so you’re saying I should be wary of any calls with js/ ?

jrychter09:06:04

@zoldar: I wrote a proof of concept back in 2009 (my "poor-man's react"), it's here: https://github.com/jwr/lemontree/blob/master/src/lemontree/tree.clj — although most of that code deals with functional rendering of the component (widget) tree using zippers and foldts.

cmdrdats09:06:10

@andrewmcveigh: I would have expected js/console, js/window, and js/document to be implicitly externed, surely?

jrychter09:06:05

Now, I can't use dynamic binding, because it's React that renders the tree. I could pass an extra parameter to all render functions, I guess. But I wanted to ask how people do it — the "flat routing table" model that we got from Ruby (I think) used by secretary, bidi, and compojure just doesn't fit React at all.

jrychter09:06:36

Maybe I'm missing something, but I just don't see how you can have menus and other components going 2-3 levels deep, mapped to URIs, and not go insane with the current "flat routing table" solutions.

andrewmcveigh09:06:13

cmdrdats: yep, js/console, etc. should be ok, but I’ve seen the “.log” get compiled down before.

jamiei09:06:57

Has anyone implemented an auth handler for secretary routing? There is a PoC referenced in this issue, but it seems to have gone quiet: https://github.com/gf3/secretary/issues/41

cmdrdats09:06:15

@andrewmcveigh: wow - that’s painful. in the externs, do I just need console.log = function(str) {};

andrewmcveigh09:06:01

unusual I agree

andrewmcveigh09:06:31

But I guess maybe they’re not expecting you to use console.log in production code?

jrychter09:06:28

I think I'll drop both secretary and bidi and stick to just using pushy (https://github.com/kibu-australia/pushy) along with my own code for dealing with URI tokens.

jonpither09:06:15

Hi, I'm trying to port this JS lib to cljsjs: https://github.com/vaiRk/responsive-fixed-data-table/blob/master/src/responsive-fixed-data-table.js. Unfortunately the source code doesn't actually run in the browser, i.e. the line "var React = require('react/addons');" doesn't work (and would require some pre-processing using browserify or something). I'm considering raising a github issue asking to make the JS browser compatible. Is this a good idea, what verbage would you use to describe the problem and work needed?

borkdude09:06:24

@dnolen: I found a little typo in the docs of mori: http://swannodette.github.io/mori/#reduce -> r should be a

zoldar09:06:57

@jrychter: at least until now, I've just used routing as a proxy for altering parts of app state but your idea makes me think it over

jrychter09:06:53

@zoldar: that works for simple apps. But if your nav hierarchy goes 3 levels deep, it just doesn't fit anymore.

zoldar09:06:51

@jrychter: makes sense, totally

jrychter09:06:45

One other thing that bothers me: I'm switching from navigation based on directly modifying app state atom to navigation based on HTML5 history. It seems the latter is noticeably slower (200ms or so). Not good.

martinklepsch10:06:26

@cmdrdats you can always try with :pseudo-names true, which is useful when debugging advanced compilation errors, but if you don’t have one I’m not sure how useful that’s going to be.

martinklepsch10:06:53

@cmdrdats: did that fix your problem? (externing console.log)

cmdrdats10:06:21

@martinklepsch: I’m still busy testing, but I think the real problem was that I didn’t require cljs.reader xD

txus10:06:33

I need to start a greenfield om SPA with a bit of dumb backend code (it’s basically an admin section interacting with postgres)

txus10:06:51

(it has authentication as well)

txus10:06:07

I’ve considered Pedestal, haven’t used it, but what are your thoughts?

minimal10:06:50

pedestal doesn’t have a clojurescript part anymore

tcrayford10:06:26

@txus: might be better to ask in #C03S1KBA2 if you're asking about the backend?

txus10:06:39

yeah, thanks simple_smile

minimal10:06:11

@txus: ah missed the om part when i read it.

txus10:06:53

I’m wondering what people are using as semi-dumb backends to their Om apps

txus10:06:05

with auth, cors and so on but not much more

minimal10:06:12

New release of pedestal look interesting

martinklepsch11:06:23

@txus: brings different tradeoffs to the table but I’ve had a good time with Firebase once.

jrychter11:06:07

@txus: I copy/paste my own skeleton app. Sente+Buddy+Ring+http-kit.

sveri11:06:57

@jrychter that's how I started my template, converting a skeleton to a template might take some time, but in the end I found it easier, especially when applying changes. Can only recommend making a template ;-)

jrychter11:06:45

@sveri: right you are, but too lazy I am for this. 😄

jrychter11:06:27

(BTW, I have this feeling of wasted work when creating lein templates, because there is no way to update an app once you create the template)

sveri11:06:20

@jrychter: Right, but that's the same with a skeleton. I upgrade my template in multiple steps. When I want to add, upgrade something (recently the switch to reader conditionals for instance) I do that on the app I am working on. Then, if it works, I commit, have the changeset available. Then I create a new application from my template, apply the changes there, make sure again they work and then apply the changes to the leiningen template. Before I also used a skeleton, but copying out only what I need was simply not doable after a certain amount of changes to the base, This way I have a clean process and can profit from the work I make for updates in future apps too.

cmdrdats11:06:42

would that be the correct way to send in the ‘renderRow’ and ‘selectRow’ functions into the constructors?

cmdrdats11:06:23

I see: v=new Qw(null,{renderRow:UC}) in the code, but nothing referencing renderRow back out - so I’m guessing it’s incorrect

cmdrdats12:06:58

@martinklepsch, @andrewmcveigh - I fixed it - The problem was the js-obj: (js-obj “selectRow” (fn [] …)) won’t work, because it doesn’t get optimised in the advanced compiler mode

cmdrdats12:06:21

I needed to

(deftype AcRender [element]
  Object
  (renderRow [this row token node]
    (render-row row token node))
  (selectRow [this entry]
    (select element entry)))

cmdrdats12:06:34

and pass an instance of AcRender along instead

andrewmcveigh12:06:26

@cmdrdats: Ah, right… I completely glossed over that bit.

cmdrdats12:06:16

@andrewmcveigh: Now I have one more issue - the (.-catname data) is being optimized to b.fH 😕

crisptrutski13:06:19

whatis amanda?

cmdrdats13:06:20

oh, it’s a frontend library of web admin components we’ve developed for our warehouse

rsslldnphy13:06:39

anyone using reagent point me to the correct way to convert a reagent component to something that a plain react component will accept in place of a function that returns jsx?

samflores13:06:03

@rsslldnphy: reagent.core/as-element

rsslldnphy13:06:01

@samflores: that prints (str component), ie something like "spanspan139487299121537751054096nil" - am i still doing something wrong?

samflores13:06:43

(r/as-element [:span "Hello world"])

samflores13:06:36

it should create a plain React component

rsslldnphy13:06:54

unfortunately the prop is expected to be a function, and that seems to return an object?

rsslldnphy13:06:02

Warning: Failed propType: Invalid prop cellRenderer of type object supplied to FixedDataTableCell, expected function. Check the render method of FixedDataTableCellGroupImpl. util.cljs:127 Uncaught TypeError: props.cellRenderer is not a function

rsslldnphy13:06:51

i can't get the page to load at all unless i wrap the hiccup in a fn, like:

rsslldnphy13:06:16

(r/as-element (fn [] [:span "Hello world"]))

rsslldnphy13:06:43

but in that case, the table renders fine but the span is rendered as a string

ul13:06:55

if you will not find solution in feasible time, try sablono's html, like :cellRenderer (fn [cell-data] (html [:span "Hi!"]))

ul13:06:58

it worked for me

escherize13:06:27

imho, for longer code snippets

:cellRenderer (fn [cell-data] (html [:span "Hi!"]))
works better

rsslldnphy14:06:00

Thanks @ul - I think I can see where you've done it in select-om-all - however I'm a bit wary of mixing reagent and sablono in the same project!

ul14:06:38

sablono is not om-tied and plays well with react components, should be safe

ul14:06:50

but I agree that finding pure reagent solution is better

ul14:06:18

especially taking in account that it claims to play well with pure react

rsslldnphy14:06:26

I guess I just need to work out what it returns and how that's different to what reagent is returning... thanks for the pointer

dnolen14:06:07

@shriphani: browsers will need to provide more hooks to support languages other than JavaScript, I’m not holding my breath

dnolen14:06:16

IDEs/editors can sort out this problem.

robert-stuttaford15:06:38

now we can use all of the stuff in npm, right? -grin-

ul15:06:36

do i correctly understand that is no need to provide extern for this type of foreign-libs?

maria15:06:00

dnolen: thank you for all your input and help simple_smile

dnolen15:06:11

@ul only if the library uses string based property lookups

dnolen15:06:46

@ul so no for React or React Native, but yes for many others

ul15:06:02

got it, thanks

dnolen15:06:34

and this only applies to advanced compilation

dnolen15:06:47

might not be relevant for Node.js or React Native

dnolen15:06:46

@robert-stuttaford: needs more testing but that’s kind of the idea yeah. I suspect we won’t be able to do much better than Browserify, some libs just aren’t going to work.

robert-stuttaford15:06:17

yeah. this is a huge step forward for overall cljs adoption, though. one less obstruction to integration into existing systems

maria15:06:54

@robert-stuttaford: thank you, but dnolen provided me with a lot of guidance for this, so applause to him too 😉

robert-stuttaford15:06:20

dnolen gets a lifetime achievement award for all he’s done for us simple_smile

robert-stuttaford15:06:32

certainly changed my career for the better

dnolen15:06:10

can finally (def xs (range)) at the REPL

escherize15:06:43

woah, nice!!

mfikes16:06:58

For CLJS-934, my attempt at explaining its effect for the end user is this blog post: http://blog.fikesfarm.com/posts/2015-06-09-def-vars-in-clojurescript-repls.html

andrewhr16:06:53

woah, nice work @maria !

andrewhr16:06:02

@dnolen: hey david, I want to take some random tickets on Jira. If I just update the assigned to me is enough to signal that this-issue-is-mine-let's-rock-mode?

andrewhr16:06:26

I think that what I really want to know is if there is some kind of formal process to inform and discover what people are working on

jeff16:06:56

Any London clojurescript devs out there?

dnolen16:06:58

@andrewhr: yes assigning a ticket to yourself is all that’s needed

tcrayford16:06:07

@jeff: you might have more luck asking in #C0522EZ9N

markstang16:06:01

@jeff: Anna Pawlicka

annapawlicka16:06:29

temporarily in Poland, but back in LDN on the 20th simple_smile

agile_geek18:06:01

@jeff try asking on #C0522EZ9N as well

jeff18:06:41

great, will do, thanks!

borkdude18:06:56

@dnolen: look what I just found. A Dutch company named Om Next! http://www.omnext.com/

borkdude19:06:48

@dnolen: yeah, sorry for the lame joke, it's already weekend here

not-much-io20:06:00

Hi everyone, I am rather new to using Cursive and I have a small problem. I open up the repl and switch to cljs. But it still seems to be a clj repl. (js/Date.) CompilerException java.lang.RuntimeException: No such namespace: js, compiling:(/home/kristo/.IdeaIC14/system/tmp/form-init2826178497227697999.clj:1:1) Fishing for help here as well as from #C050AN6QW simple_smile

dnolen20:06:02

@not-much-io: have you read the ClojureScript Quick Start?

not-much-io20:06:59

@dnolen I have at some point, but didn't think I'd get much regarding Cursive there -> https://github.com/clojure/clojurescript/wiki/Cursive I was thinking I am just doing something wrong.

dnolen20:06:31

@not-much-io: not true, you need to understand the Quick Start to understand how to get a ClojureScript REPL in Cursive.

not-much-io20:06:42

@dnolen Huh... hmm, I was expecting Cursive to just work, it seemed to have the everything covered, judging by the cljs option in the repl. Okay, I will look at the getting started guide. Thanks. simple_smile

dnolen20:06:29

@not-much-io: it’s not really possible for it to “just work” in general, ClojureScript REPLs needs a JS environment in order to function

dnolen20:06:41

so you need to supply browser, Node.js, iOS, Nashorn, etc.

not-much-io20:06:50

@dnolen: I am also using fighwheel in a terminal window, is the workflow supposed to be that figwheel and your normal REPL (for exploratory coding) are separate?

dnolen20:06:43

not at all, just figure out how to start a figwheel REPL w/o lein

dnolen20:06:56

then use Cursive’s raw REPL option with whatever script you have that does that.

not-much-io20:06:59

Alright, seems good. Thanks for the input.

dnolen20:06:15

working through ClojureScript bootstrap is fun simple_smile we’re very close now.

not-much-io21:06:21

@shaun-mahood: Not yet, but I will. Looks helpful, thanks. (y)

jackjames21:06:26

the figwheel wiki method works, but there's a different figwheel/cursive workflow that is more along the lines of what @dnolen just described: https://www.refheap.com/101322

jackjames21:06:36

not really battle-tested, but seems to work here. nice to just open your project, mash the green button, and end up at a figwheel brepl (in the cursive repl pane)

jackjames21:06:38

here's a repo that you can just 1) clone 2) import into intellij/cursive, 3) hammer the green button: https://github.com/heretodaygonetomorrow/hey-kanye

not-much-io21:06:12

Nice, will check out. Many thanks.

jackjames21:06:15

and then you'll probably want to update deps because it's been approx. 4 days since the repo was published and it's already 100s of commits behind cljs and everything else

ivar22:06:26

@dnolen: do you know if/when your presentation at qcon ( https://qconnewyork.com/ny2015/presentation/demand-driven-architecture ) will be made available online ?

dnolen22:06:19

@ivar I don't know

dnolen22:06:33

As far the video

mfikes23:06:01

@ivar last year they put up a page with a 5-month schedule of video releases