Fork me on GitHub
#clojurescript
<
2015-08-18
>
mattly02:08:16

is it …possible at all to access the js namespace from a cljc file?

mattly02:08:59

I’m sticking a reference to js/JSON behind a reader conditional and the compiler is complaining about “no such namespace js"

mattly02:08:10

nvm, figured it out

mattly02:08:56

I was using the reader macro for dispatch in the wrong place

mattly02:08:12

any use of the js namespace in cljc MUST be hidden behind a reader macro

danielcompton03:08:25

@mattly: yep, you’ve got it

meow03:08:04

@danielcompton: I read that several days ago and thought it was really well-done, so keep promoting it simple_smile

niwinz05:08:10

@danielcompton: maybe you want integrate your article into the clojurescript-unraveled book (http://funcool.github.io/clojurescript-unraveled/)?

niwinz05:08:58

It is pretty fine and we don't have anything written about this at this moment

onetom05:08:39

im playing with clojurescript on ec2 w more than 8 cores and it seems only 8 core is used. is there any way to up it somehow? JVM_OPTIONS maybe?

onetom05:08:57

actually #C03S1KBA2 would be a better channel to ask maybe?

danielcompton05:08:42

@niwinz: how would you envision it being added? Just another chapter, or a link in the appendix or further reading?

niwinz05:08:32

I have thought in an other appendix entry. Like the core.async and figwheel

niwinz05:08:58

But, we have the reader chapter also unwritten

niwinz05:08:56

I think that the best way now,... is adding it as appendix entry. Later, we can transform it to be part of the reader chapter

niwinz05:08:00

What do you think?

danielcompton05:08:41

I’l have to think about it, I’d probably want to edit it to make it more cljs specific

danielcompton05:08:50

I’ve put it on the todo list simple_smile

niwinz05:08:57

Thank you very much. Having similar content to on the book will be a great point of reference on reader conditionals 😄

grav06:08:54

Is there a defacto way of handling asynchronicity in Cljs apps, like there is promises in Javascript ES6 (and callback hell in Node/ES5)?

grav06:08:15

core.async is a bit low level in itself, but I see both FRP libs and Promises built on top. Just wondering what people are using

niwinz06:08:13

I think there no defacto standard. I have done this package for facilitate the usage of promises in cljs (https://github.com/funcool/promesa)

niwinz06:08:52

I'm usually combine the usage of core.async with promises

niwinz06:08:20

core.async just for communicating processes and seq related stuff

niwinz06:08:42

and promises for asynchronous results

niwinz06:08:40

You can use cats library for make the promises composition more likely the ES6 async/await

grav06:08:17

@niwinz: that looks very cool. do you have any examples where you combine core.async with promises?

niwinz06:08:31

@grav I'm not undertand properly your question. You can use core.async for communicating processes and promises for asynch results (api calls or somethig similar)

niwinz06:08:23

This is how I use the both abstractions

grav06:08:58

ah, ok. i think i follow. it’s the api calls that’s my main problem. I used promises when doing es6, so I’m sure promesa will be familiar

jonpither08:08:06

Anyone recommend an approach/lib for embedding stylish charts (such as d3) into an Om/react webapp?

acron08:08:41

jonpither: iirc there's an example in the om-cookbook which uses dimplejs for charts

jonpither08:08:54

@acron: thanks for that. Going to pay om-cookbook more heed in future

grav09:08:08

@niwinz: weird, I did a clean and then I get another error:

grav09:08:26

clojure.lang.ExceptionInfo: Could not locate cats/core__init.class or cats/core.clj on classpath:  at line 26 file:/home/grav/.m2/repository/funcool/cats/0.5.0/cats-0.5.0.jar!/cats/core.cljc {:tag :cljs/analysis-error, :file "file:/home/grav/.m2/repository/funcool/cats/0.5.0/cats-0.5.0.jar!/cats/core.cljc", :line 26, :column 1}
	at clojure.core$ex_info.invoke(core.clj:4403)
	at cljs.analyzer$error.invoke(analyzer.clj:380)
	at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1859)
	at cljs.analyzer$analyze$fn__2126.invoke(analyzer.clj:1953)

grav09:08:07

do I need to do an explicit dependency on cats 0.5.0?

niwinz09:08:34

This is caused by the dependency conflicts, some of your packages are requiring cats 0.5.0 y other some 0.6.1 and them both are incompaibilities

niwinz09:08:48

I just now working in update the promesa to the latest cats dependency

niwinz09:08:07

@grav try to use the 0.4.0 of promesa

niwinz09:08:19

perform a clean also!

Petrus Theron09:08:03

I'm having a hard time with Sente. I followed the instructions to the letter, but when my cljs frontend connects to my backend, all I see is a slew of these errors: ' failed: Invalid frame header. Could it be related to running sente on a different port (localhost:3011) from the origin of my HTML (localhost:3010)?

Petrus Theron09:08:46

So Chrome throws Invalid frame header and Safari throws Compressed bit must be 0 if no negotiated deflate-frame extension when sente attempts to connect.

grav09:08:28

@niwinz: I get this:

clojure.lang.ExceptionInfo: clojure.lang.Symbol cannot be cast to clojure.lang.Namespace at line 25 file:/home/grav/.m2/repository/funcool/promesa/0.4.0/promesa-0.4.0.jar!/promesa/core.cljs {:tag :cljs/analysis-error, :file "file:/home/grav/.m2/repository/funcool/promesa/0.4.0/promesa-0.4.0.jar!/promesa/core.cljs", :line 25, :column 1}
	at clojure.core$ex_info.invoke(core.clj:4403)
	at cljs.analyzer$error.invoke(analyzer.clj:380)
	at cljs.analyzer$analyze_seq.invoke(analyzer.clj:1859)
	at cljs.analyzer$analyze$fn__2126.invoke(analyzer.clj:1953)
	at cljs.analyzer$analyze.invoke(analyzer.clj:1946)
	at cljs.analyzer$analyze_file$fn__2177.invoke(analyzer.clj:2190)
	at cljs.analyzer$analyze_file.invoke(analyzer.clj:2185)
	at cljs.analyzer$analyze_deps.invoke(analyzer.clj:1262)

niwinz09:08:58

That cljs compiler you are using? That are very strange errors.

grav09:08:01

sorry, added the missing error on top

grav09:08:07

I’ll try up’ing cljs

grav09:08:33

that helped

grav09:08:05

maybe that was the problem all along. lein deps :tree didn’t yield any other dependency on cats other than 0.5.0

niwinz09:08:00

Can you paste you dependency tree?

niwinz09:08:10

you can do it in private message or in #C093UFM4M channel

niwinz09:08:37

for avoid innecesary "spam" here

onetom11:08:18

@grav: we are using http://hoplon.io which solves reactivity using a small data-flow library called Javelin https://github.com/tailrecursion/javelin/ and connects to backends using https://github.com/tailrecursion/castra/ (which uses transit as its transport layer) Since then we didn't have to fuck around with callbacks or promises AT ALL.

afhammad11:08:50

Is something like Sierra's Component library the best way to manage a CLJS app, specifically when it comes to sharing or passing config in a DRY manner?

grav12:08:02

@onetom: thanks, I’ve heard a brief cognitect podcast about it, but I haven’t dived into it yet.

grav12:08:21

I’m just thinking we’re too deep into Om as it is currently

grav12:08:31

But I’ll check it out simple_smile

onetom12:08:35

react's lifecycle management can get quite complicated. javelin + hoplon offers a loooot lot lot simpler yet similarly powerful way of dealing with reactivity...

grav12:08:25

cool. but where react only concern itself with the view part, hoplon sounds a bit more framework-y,

onetom12:08:00

not at all, that's why i was mentioning the 3 separate components

onetom12:08:33

though it indeed depends on javelin, but not on castra

ul12:08:54

why does (identical? :x :x) is false in cljs ? I understand why it is technically, but I assume that true is expected behavior. Or Clojure's language spec leaves this moment undefined?

onetom12:08:55

@grav: u can hop on the #C08BDAPRA channel for further discussions. u wont regret it 😉 btw, here is a piece of code we open sourced which is a nice show case of hoplon: https://github.com/exicon/homepage/tree/hoplon6 we are just migrating it to the latest version of it.

jonpither12:08:40

Anyone got Cider + clj-refactor working to clean up cljs ns forms? It kills my Emacs simple_smile

slipset12:08:23

@jonpither: Rumours has it that http://github.com/expez is working on it as we speak.

slipset12:08:47

or at least working on the middleware to work with cljs

mfikes12:08:00

ul: There is cljs.core/keyword-identical? (I don’t know the history / rationale.)

grav13:08:39

@niwinz: It seems promesa converts my PersistentArrayMap into a js object

grav13:08:56

(-> (p/promise {:foo 2})
    (p/then (fn [r] 
              (println "type: " (type r))
              (p/all [r])))
    (p/then (fn [[r]]
              (println "type: " (type r)))))

grav13:08:14

This yields:

type:  cljs.core/PersistentArrayMap
type:  #object[Object "function Object() { [native code] }”]

niwinz13:08:55

Oh, very strange! Thanks to notice me! I'll try check it in some moment

grav13:08:04

Only if I use p/all

grav13:08:17

If I use

(-> (p/promise {:foo 2})
    (p/then (fn [r] 
              (println "type: " (type r))
              r))
    (p/then (fn [r]
              (println "type: " (type r)))))

grav13:08:23

It stays a PersistentArrayMap

grav13:08:44

I’m using 0.4.0, I’ll try using 0.3.x

niwinz13:08:37

Hmm in case of all, I suspect that you cant use the destructuring

niwinz13:08:47

because the result of p/all is a promise that returns a js array

niwinz13:08:52

as result value

niwinz13:08:13

you can use the p/spread just for this case

niwinz13:08:41

(p/spread promise (fn [param1 param2 ...] ...)

grav13:08:53

cool, i’ll look into it

niwinz13:08:09

This is happens on how js promises works on the background

niwinz13:08:38

the all operator just collect the result of all promises in one array and resolves the resulting promise with that array

grav13:08:26

i’m using p/all a lot since i want to carry over my results from previous then’s. Maybe it’s not idiomatic?

niwinz13:08:26

and in your first snippet of code you are trying destructurre the js array

niwinz13:08:55

Hmm, p/all is a syncronization primitive

niwinz13:08:14

if you want you result from other promise just resolve a vector...

niwinz13:08:20

without p/all

grav13:08:26

ah, yes.

grav13:08:29

good idea

niwinz13:08:47

and then, yo don't need spread and you can use the standard cljs destructuring

grav13:08:24

at least I think I understand 😉

grav13:08:50

can I resolve another promise together with some value in a then?

grav13:08:12

Currently my code looks something like this:

(-> (async1)
      (p/then (fn [r1] 
          (p/all [r1 (async2)])))
      (p/then (fn [r1 r2]
          (prn r1 r2))))

grav13:08:10

how do I resolve both the result of async2 (a promise) and r1 in the first then?

grav13:08:20

without using p/all

grav13:08:06

Where it’s also suggested to use all and spread together

grav13:08:15

Seems bluebird even has a join for this

grav13:08:11

though spread seems to have the same problem, converting my persistent arraymap into a js object

niwinz13:08:12

For the use case that you are explaining you should use (-> (async1) (p/then (fn [r1] (p/all [r1 (async2)]))) (p/spread (fn [r1 r2] ...))

niwinz13:08:01

But the best way to do it is just (-> (p/all [(async1) (async2)]) (p/spread (fn [r1 r2] ...))

niwinz13:08:35

If you have an async operation that depends on the result of other, the best way is use cats mlet

niwinz13:08:40

(require '[cats.core :as m])
(m/mlet [r1 (async1)
         r2 (async r1)]
  (some-operation r1 r2))

grav13:08:51

okay. it’s the last thing - async2 is dependent on async1

grav13:08:14

and p/spread gives me a js object instead of a PersistentArrayMap

grav13:08:34

I may look into mlet, looks nice simple_smile

niwinz13:08:06

The mlet return value is an other promise that will be resolved with the last expression on the block.

niwinz13:08:29

Take a look in the documentation examples on the spread http://funcool.github.io/promesa/latest/#parallelism

niwinz13:08:37

Take care that mlet is a macro and you should properly include it in cljs...

niwinz13:08:56

(:require [cats.core :as m :include-macros true])

sdegutis14:08:56

Are any of you using ClojureScript + Node.js (or Io.js) on the server-side instead of Clojure + JVM ?

pxlpnk14:08:42

sdegutis: not yet, but I am looking into this currently in combination with aws lambda

pxlpnk14:08:55

you have any pointers/docs?

sdegutis14:08:08

None at all. Just in research phase.

tranchis14:08:07

does anyone here use chestnut?

pxlpnk14:08:38

sdegutis: I started playing with this template: https://github.com/swannodette/mies-node-template

sdegutis14:08:49

@pxlpnk: says "DEPRECATED. This template is no longer maintained." at top.

pxlpnk14:08:32

sdegutis: indeed. I am actually more looking into how the project is set up.

pxlpnk14:08:36

also using lein-npm

sdegutis14:08:21

I'd be interested if there was eventually a way to move away from Leiningen altogether and just use npm for all ClojureScript dependencies and gulp/etc for build needs.

sdegutis14:08:46

@dnolen: Any particular reason you deprecated that template btw?

bensu15:08:59

@sdegutis: you can move away from leiningen altogether as long as you are willing to manage your jars dependencies for yourself

bensu15:08:12

if i recall correctly the mies-node-template was deprecated because "no time to mantain two mies templates" so the node part was added to the main mies. luckly @maria stepped up and started mantaining the main mies

pxlpnk15:08:22

but the mies template adds all kinds of browser stuff or am I mistaken?

sdegutis15:08:26

@bensu: I was kind of hoping that ClojureScript would move entirely away from jars at some point, and be a pure JavaScript lib that only uses JS ecosystem tools.

sdegutis15:08:31

(and not the JVM at all)

blissdev15:08:09

unfortunately I don’t think it’s going that way

nullptr15:08:02

that would require dumping closure compiler, which is written in java

nullptr15:08:29

could probably stay non-jvm for dev use cases, but you need gcc to get to production

bensu15:08:51

@sdegutis: paraphrasing others "that will never happen" but I agree with @nullptr and do think there is place for a JVM-free ecosystem, specially targeted towards build tools and command line programs. Targetting browsers is very hard without the Google Closure Compiler.

sdegutis15:08:27

It seems like Immutable.js + ES6 + Sweet.js gets pretty close to doing exactly what ClojureScript offers. A little wrapper library to pull them altogether could probably look almost identical to ClojureScript code.

sdegutis15:08:40

Macros, destructuring, immutable data structures, these seem like the killer features of ClojureScript. Am I missing anything?

nullptr15:08:58

nicely integrated google closure should not be underestimated — both the library and the compiler

nullptr15:08:29

emphasis nicely integrated — it’s accessible to js developers today, but nobody uses it because it doesn’t fit the toolset

nullptr15:08:08

core.async is also novel

nullptr15:08:36

and i quite like hiccup over jsx or templates

nullptr15:08:44

oh, and this stuff is mostly years old and stable … and the tooling around it is sane

nullptr15:08:41

and some of the newer stuff like figwheel is

sdegutis16:08:07

@nullptr: Good point about core.async. Hiccup could probably be reproduced using the aforementioned combination (ES6, Sweet.js, Immutable.js). I'm pretty sure general JS community consensus is that the Google Closure library and compiler are terribly designed and should be avoided, and I agree with their reasoning.

nullptr16:08:07

The general JS community consensus re: Google Closure is “what’s that?” and “looks hard”. The notion that either are terribly designed or should be avoided is silly.

bensu16:08:52

@sdegutis: when it comes to design I don't listen to the Js community. The Google Closure compiler makes ClojureScript practical for browser use, and the modules make things like Figwheeel possible so we generally like it here simple_smile

sdegutis16:08:14

@nullptr: Okay maybe I shouldn't speak for the whole community then lol. Either way, I think it's not a great design. In fact I'm quite a bit biased against everything they've done except web search and gmail.

sdegutis16:08:31

I mean, biased because all of it sucks (Dart, Go, Closure, etc)

sdegutis16:08:15

Okay maybe "sucks" is a bit harsh. But for a company of their stature, they could do better.

swizzard16:08:14

i have to say, i’ve hacked on some ChromeOS stuff

swizzard16:08:18

and it’s…something

sdegutis16:08:19

@swizzard: something good or something bad?

juhoteperi16:08:17

Closure is perhaps only one of mentioned techs used in search and gmail

swizzard16:08:57

@sdegutis: I’d say it’s not great? their python code is hell of unidiomatic, at least

swizzard16:08:34

also the fact that they seem to have like, 9 different build systems isn’t exactly encouraging

dottedmag16:08:25

@swizzard: only 9 build systems for a company so large is pretty awesome achievement.

swizzard16:08:59

there seemed to be at least 2 used in ChromeOS alone

swizzard16:08:08

and it wasn’t clear which should be used when

swizzard16:08:19

i think i remember that one was being deprecated or something

swizzard16:08:23

but it was not clear

sdegutis16:08:42

Okay, thanks for adding to the list of anecdotes that confirms my bias against Google's development tools and code.

dottedmag17:08:19

@swizzard: If you wander into a large software development company, you'll often find dozens of build systems, often used by a single team.

swizzard17:08:14

i believe that

swizzard17:08:24

it just struck me as messy

swizzard17:08:41

and like, unmanaged?

swizzard17:08:57

the choice of systems seemed kind of arbitrary

swizzard17:08:02

what do i know

dottedmag17:08:50

It definitely messy and unmanaged. However keeping 0.0002 build systems per employee is still pretty awesome.

dottedmag17:08:47

How does symbol resolution work? I have tested that (:require [foo :refer [bar]]) does not create var bar in a current namespace, and `bar resolves to foo/bar, but how does it work?

pandeiro17:08:55

@juhoteperi: did you figure out what was causing that src/`src2` issue with cljs.test?

pandeiro17:08:34

@juhoteperi: I saw that, nice work! I don't have time to investigate now, and adding :init-fns solved the stale test issue with boot-cljs, but I hope to revisit this

pandeiro17:08:57

I guess I was just wondering if you feel pretty confident the issue is in cljs itself?

juhoteperi18:08:30

@pandeiro: Looks like the problem is reproducible even without cljs.test

pandeiro18:08:26

@juhoteperi: is it just any time there's multiple source directories? it's surprising

juhoteperi18:08:07

Could be related to :main ns being on different directory

juhoteperi18:08:50

Or well, :main ns shouldn't be any different.

juhoteperi18:08:40

Strange, after compilation compiler-state contain the new var

juhoteperi18:08:33

I guess if core-ns macro-expansion is done before test-ns is reanalyzed it could cause this

spinningtopsofdoom18:08:12

@juhoteperi: try using (build/inputs "src" "src2")

spinningtopsofdoom18:08:40

build/inputs is in the cljs.build.api namespace

juhoteperi18:08:58

@spinningtopsofdoom: Thanks.... that indeed fixes the problem picard-facepalm

spinningtopsofdoom18:08:06

NP I only found it by looking through David Nolens builds to find out a way to replicate cljsbuild. It could definitely use better documentation.

juhoteperi18:08:18

I thought build source only mattered for main namespace, as I did some testing and couldn't find any reason to list other source dirs

juhoteperi18:08:52

And I wrote that down on boot-cljs comments so I though it was documented behavior 😄

joelmccracken19:08:44

has anyone been working on node.js applications with clojurescript?

joelmccracken19:08:05

also, is core.typed usable with clojurecript?

andrewboltachev19:08:14

@joelmccracken: I have recently compiled cljsfile and ran it on Node.js. Not sure about core.typed

joelmccracken19:08:46

did you have to do anything funny?

dottedmag19:08:26

Is there a way to run Node-backed REPL without creating a project? Similar to lein repl, that can be used everywhere. I'd expect something like lein --plugin=lein-noderepl trampoline noderepl.

dottedmag19:08:11

Oh, my bad, it's in README for lein-noderepl.

pandeiro20:08:10

@juhoteperi: @spinningtopsofdoom: thanks so much for the fix! awesome

not-much-io20:08:03

I have a powerful desktop computer at home that I'd like to use remotely via my chromebook. I have everything set up, however I'm not sure how figwheel works exactly... With lein figwheel running and changing code: Desktop: localhost:3449 gets updated Chromebook: [my ip]:3449 I can load the page but no figwheel updates happen Can this be made to work at all? Thanks for any input.

malcolmsparks21:08:51

@not-much-io: you could use ssh port forwarding to achieve remote access to your home desktop

domkm22:08:51

pupeno: Hi

Pablo Fernandez22:08:14

domkm: do you have a couple of minutes to answer a question?

domkm22:08:15

pupeno: Saw and tweeted your blog post, btw. Good stuff. 😄

Pablo Fernandez22:08:28

domkm: oh, thanks simple_smile

Pablo Fernandez22:08:25

Today at the London Project Clojure Dojo we were trying to figure how to do server side rendering of a SPA and we arrived at your omelette which we successfully run on our own machines.

not-much-io22:08:28

@malcolmsparks: I have already achieved remote access for emacs and to to the port I want to observe the web app on. The problem is that the web app is not getting updated on the chromebook while it does get updated on the localhost.

Pablo Fernandez22:08:30

domkm: we found out how you are doing the server-side rendering but when we tried to apply it we got an error about document not being defined, from the javascript engine. I was wondering, before I go in a witch hunt, if this rings any bell? Our generated JS is quite different to your JS.

domkm22:08:29

pupeno: document is not defined in Nashorn. neither is window or many of the objects in a browser JS environment.

Pablo Fernandez22:08:51

domkm: how do you work around that in omelette?

pandeiro22:08:28

@pupeno: not omelette but i've worked around that issue -- there's an example here: https://github.com/pandeiro/agua

pandeiro22:08:33

(in the README)

domkm22:08:38

pupeno: Leave all the rendering and DOM stuff to React. Try not to do any of it manually. When you have to access browser APIs, put that logic in lifecycle methods that only run in the browser, like componentDidMount.

Pablo Fernandez22:08:04

domkm: mh, ok, I’ll look into that.

Pablo Fernandez22:08:17

pandeiro: how did you workaround it?

domkm22:08:18

pupeno: Let me know how it goes. simple_smile

pandeiro22:08:19

@pupeno: in my naive impl there, parts of the react tree that only make sense to render in the browser have a conditional

pandeiro22:08:28

as simple as (when js/document ...)

pandeiro22:08:58

and then the main app init function has (if js/document (render ...) (render-to-string ...))