Fork me on GitHub
#clojurescript
<
2016-07-05
>
vikeri08:07:16

Could someone with >1500 points on Stackoverflow go in and tag this question with cljsrn? A custom tag for react native in clojurescript would help our small community to share knowledge a bit more efficiently: http://stackoverflow.com/questions/38198511/how-to-prevent-node-from-running-out-of-memory-when-bundling-js-for-react-native/38198512#38198512

vikeri08:07:40

Should maybe have been posted in off topic btw...

vikeri11:07:04

Can I do this more elegantly #(= (type (goog.date.Date.)) (type %))? #(instance? goog.date.Date %) does not work since it does not make difference between a goog.date.DateTime and goog.date.Date.

dhruv114:07:04

any good web development tutorials in clojurescript?

dhruv114:07:28

i am totally new to web development (but not new to clojure) and I am totally lost on where to start

vikeri14:07:42

@dhruv1: I’m using re-frame and find its readme quite informative. That plus the reagent site would give you insight in some essential parts of web dev in cljs. Not really tutorials though. https://github.com/Day8/re-frame http://reagent-project.github.io/

vikeri14:07:13

And om/om.next are also very popular: https://github.com/omcljs/om

dhruv114:07:31

@vikeri: thanks! I’ve looked at the re-frame concept and love the idea of flow of data in one direction

lewix14:07:00

dhruv: lambdaisland has some nice videos

dhruv114:07:50

I’m so new to web development that there are times I have no idea to get things going. i.e: how to style things or even get started on how to style things.

dhruv114:07:07

i think i just answered my own question on where to get started.

dhruv114:07:57

awesome. thanks

akiva14:07:48

This is also a good resource; I relied on it a lot when learning CLJS. https://funcool.github.io/clojurescript-unraveled/

dhruv114:07:26

@stephen_turley: thanks. i read tutorial_01 and looks pretty good!

dhruv114:07:59

@akiva: thanks. i’ve been doing clojure for a year and i know some of the basics. FP is new to me and so far it’s damn good. i know there are some differences between clojure and clojurescript. thanks for the link!

akiva14:07:09

Yeah, it’ll definitely shuffle your approach toward writing software even when you’re stuck coding in a non-FP language.

lewix14:07:14

funny enough that's something I haven't validated yet

lewix14:07:38

I'm not sure why or how it has been scientifically proven that it makes one more productive. I love the philosophy though

bostonaholic14:07:13

I don’t believe there are FP languages and non-FP languages. To me, FP is a style of programming.

bostonaholic14:07:06

Writing clojure for so long, when I’ve gone back to Java or Ruby, I take an entirely different approach to writing code than I had before.

lewix14:07:08

bostonaholic: there are however languages that make it easier to do FP

bostonaholic14:07:57

sure, there are languages that are more conducive to FP

lewix14:07:36

bostonaholic: which remind me last time i had to use #unshift in ruby, it was bugging my mind that there was not an equivalent method that did not return a new array. I ended up avoiding unshift and using something different so that it does not change in place

akiva14:07:03

I dunno. Once I got a taste of FP with F#, it ‘infected’ how I coded C#. More Action<T> and Func<T> action, for example.

bostonaholic14:07:11

the pillars of FP (to me) are function purity and immutability

bostonaholic14:07:51

and those two can be followed in almost any language

lewix14:07:08

bostonaholic: I've been doing it all along with javascript - purity and immutability.

akiva14:07:17

@bostonaholic, yep. And I began writing data structures that were as immutable as I could make them in C#. And most of my methods returned new objects rather than modifying the one passed by reference.

bostonaholic14:07:29

well, javascript is a FP language IMO

bostonaholic14:07:48

(if you believe there are such things 😉 )

lewix14:07:49

bostonaholic: aren't you contradicting yourself...

lewix14:07:03

"I don’t believe there are FP languages and non-FP languages. To me, FP is a style of programming."

bostonaholic14:07:27

right, but for people that belive there are FP languages, javascript would classify as one

lewix14:07:00

bostonaholic: what about golang?

bostonaholic14:07:28

I’m not familiar with go

bostonaholic14:07:43

we’re a bit off-topic for #clojurescipt I think

bhauman14:07:27

@bostonaholic: yes in any language you can write functional code, the question is "is it idiomatic to write functional code in this language?"

bhauman14:07:05

I'm paraphrasing Rich there

bhauman14:07:56

and when its not idiomatic, good luck keeping a large shared codebase functional

bostonaholic14:07:49

I’m not suggesting that we write Java in 100% pure functions and no mutations

bostonaholic14:07:10

Gary Bernhardt has a great talk on “functional core, imperative shell” which describes a lot of what I’m talking about

bhauman14:07:08

a language that is imperative first is going to have a gravity that pulls code in that direction, and the consequences are pretty obvious at this point

bhauman14:07:24

cool I'll look into those talks

bostonaholic14:07:26

we could move some of this to #C1NTZQA5Q

benedek15:07:22

hi gals/guys any idea how to increase the javascript heap size for clojurescript/node.js repl?

benedek15:07:03

i am using leiningen btw to start it up, something like: rlwrap lein trampoline run -m clojure.main scripts/repl.clj

benedek15:07:20

clojure is naturally 1.8

peeja16:07:07

What's the canonical way to ask if a JS object has a particular property?

peeja16:07:27

aget and check for js/undefined? Or is there something better, like a contains??

peeja16:07:59

goog.object/containsKey?

peeja16:07:59

(exists? (aget js-obj "some-key"))?

peeja16:07:21

That should work too. I think I'm going to run with goog.object/containsKey, though.

jr16:07:04

@peeja: contains? will handle undefined and nil

jr16:07:19

cljs.user=> (contains? js/undefined :foo)
false
cljs.user=> (contains? {:foo "bar"} :foo)
true

peeja16:07:43

@jr: No, I'm looking for something like (contains? #js {:foo "bar"} "foo")

metametadata17:07:23

@peeja: how about (.hasOwnProperty obj "key")?

peeja17:07:00

@metametadata: Oh, yeah, good call! Thanks!

dfcarpenter18:07:10

I’m having trouble figuring out how to get event handlers working for svg elements with reagent. I’m generating a group of circles in a for loop and attaching an on-mouse-over event to each one. I can’t seem to get this to work. The same event handler seems to work fine for other html elements so not sure what the problem is.

rohit19:07:19

@peeja, @jr, @metametadata: depending on the use case, goog.object/containsKey may be a better bit. it does a in lookup. Doc for hasOwnProperty is worth reading: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty

isak19:07:09

has figwheel changes behavior on which files to reload recently? seems to take much longer than before

shaun-mahood20:07:04

@isak: What versions did you move from/to?

isak20:07:22

@shaun-mahood: figwheel-sidecar "0.5.2" -> "0.5.4-4"

isak20:07:35

but I also updated clojurescript and other dependencies, so it could be something else. just wondering if anyone else has noticed anything.

johanatan20:07:38

hi, is it possible to create react components to embed within an existing react javascript application?

johanatan20:07:03

[everything I have found seems to imply the opposite relationship-- i.e., using javascript components inside a clojurescript app]

shaun-mahood20:07:52

@isak: 0.5.4 was a pretty massive release, but I followed pretty much the same type of upgrade and haven't noticed any issues. Based on the changes that were made I think it should have sped things up for recompilation, but I think there were a couple of edge cases discussed in #C0B22RS2Y that had some new options - probably worth asking in that channel and seeing if anyone else is seeing the same problem, I can't find the specific issues I'm thinking of in either the slack log or my memory.

isak20:07:32

@shaun-mahood: good to know, thanks

montanonic20:07:10

Hey y'all, it's been a long time since I've done front-end stuff, and I'm going back to it so I can build out a good-looking blog and show some of my work on it. So I'm not really going to be building an app, but it's not by any means going to be static either. What tools would you recommend to build something like this? I'm wont to avoid writing any raw HTML or CSS because they can't be manipulated well, and I'd prefer to compose CSS if possible rather than using inheritance.

montanonic20:07:57

I'm really keen on getting into Om in the future, but it seemed too heavy for something like this. Though, if anyone can attest otherwise, I'd definitely be interested in learning it for this. I'm just very unfamiliar with the ins and outs of the CLJS library ecosystem, so some recommendations for HTML/CSS augmenters would be great, along with advice on using basic JS for animations vs. a Clojurescript lib.

isak20:07:00

@montanonic: for a css alternative you might like this one: https://github.com/noprompt/garden

montanonic20:07:49

Indeed, thank you.

isak20:07:55

@montanonic: for the general app, you may want to check out some of these lein templates: https://www.google.com/#q=lein+template+clojurescript+garden

montanonic20:07:47

That's quite helpful. Thank you.

ag21:07:22

anyone used React’s on-paste event handler? what’s the right syntax to retrieve the value? upd: nvmd: figured that out (-> e .-clipboardData (.getData "Text"))

johanatan21:07:35

can anyone answer my question?

ag21:07:37

@johanatan: you want to create CLJS React-components that’d be used in js app?

ag21:07:26

yeah, that can be done

ag21:07:04

although I don’t think ever seen anyone doing that

ag21:07:35

it depends of what exactly you want - if you want something written in CLJS and then publish the resulting thing on npm - it’s one thing, if you want to use cljs in a javascript app, that something else

johanatan21:07:00

But the former would work too if the latter is prohibitively expensive

ag21:07:07

both are doable, for the second case I would probably create a few gulp tasks to manage cljs compilation

darwin21:07:19

is it possible to mark protocol as deprecated to generate compile-time warnings?

darwin22:07:42

got it, as simple as (defprotocol ^:deprecated IMyProtocol…

johanatan23:07:55

@ag: would you use the gulp-clojure plugin?

johanatan23:07:59

Also reagent seems to prefer lein/figwheel for compilation. Can that be made to work with gulp?

ag23:07:00

@johanatan: figwheel uses repl, for developing cljs components I would still use lein/figwheel. It’s hard to recommend something I’ve never done before, but I would probably just keep lein/figwheel and gulp task that consumes compiled javascript pieces running in parallel

johanatan23:07:42

@ag ahh yea that's what I was thinking as well.

johanatan23:07:18

What do you mean by the "running in parallel" bit tho? The project in question already uses web pack to pack together different bits of JS for each page if that's what you mean

ag23:07:50

@johanatan: so, you see feeding webpack output into CLJS (or I rather should say Google Closure compiler) pipeline is not very straightforward, whereas the opposite way (feeding output of CLJS compiler) into webpack is quite straightforward