Fork me on GitHub
#clojurescript
<
2016-05-06
>
risto01:05:18

is there a way to introspect cljsjs packages?

risto01:05:32

I'm trying:

cljs.user=> (cljs.repl/dir cljsjs.d3)
nil

sbmitchell01:05:22

interesting question..Id like to know the answer to that. Is there a reason why you cant just look at the libraries docs?

risto02:05:34

i find using dir/docs to be faster

sbmitchell02:05:15

maybe since its not like a ns cljs thing it doesnt work?

risto02:05:16

I'm still pretty new to clojurescript, im missing that from some of my python background

sbmitchell02:05:37

I mean cljsjs is just js packages with proper externs to use inside of cljs projects

risto02:05:53

I don't see why at least dir wouldn't work, or at least would be able to work in the future

sbmitchell02:05:58

Im just conjecturing though šŸ˜›

risto02:05:13

yeah good point

risto02:05:04

is there a way to get figwheel to read a new dependency in the config without rebooting it?

sbmitchell02:05:17

I think I've tried to use the built-in commands like (build-once ...) to accomplish that and I'm like 99% sure it didnt work.

sbmitchell02:05:57

I end up just ctrl+c and re-running..

currentoor05:05:04

Iā€™d like to develop two cljs projects simultaneously. How is this usually done?

currentoor05:05:13

Is there something like lein checkouts for cljs?

madvas07:05:18

Guys, how do I do println, but with quoted strings?

madvas07:05:06

okay, got it: prn simple_smile

chrisetheridge07:05:57

Does anyone know any good resources for building client side apps, using event sourcing?

pastafari07:05:09

biscuitpants: have you seen re-frame?

borkdude07:05:11

@joost-diepenmaat has a library revolving around event sourcing: https://github.com/rill-event-sourcing/rill (never used it myself)

pastafari07:05:24

biscuitpants: this talk might also help https://www.youtube.com/watch?v=qDNPQo9UmJA

joost-diepenmaat08:05:46

biscuitpants also depends on what you want to doā€¦ rill is mostly a server-side toolkit; the clojurescript ā€œclientsā€ we built for it were intended to synchronize with the server and we handled consistency etc there. if you need a client-side only/mostly framework then itā€™s not going to be very useful.

joost-diepenmaat08:05:50

something like re-frame might be a better fit then

chrisetheridge08:05:54

thanks for the links guys, and yeah iā€™ve seen re-frame! amazing readme, wow

chrisetheridge08:05:10

also stumbled upon rill this morning, but i want to build the es system myself

chrisetheridge08:05:16

iā€™d love to get my hands real dirty, hence doing that

chrisetheridge08:05:33

iā€™m dying to learn the theories behind es, especially in the context of client side apps

chrisetheridge08:05:41

will definitely take a look at rill though for ideas

joost-diepenmaat08:05:11

if you have questions regarding rill just ping me. the documentation is very much lacking, I know...

chrisetheridge08:05:17

thank you @joost-diepenmaat. most definitely will!

bojan.matic08:05:46

can i wrap any arbitrary old react components that i find online in cljs?

urbanslug08:05:22

I have a function that makes an async delete call. However, when it fails I want to retry maybe x3.

urbanslug08:05:06

Which is the best way to write the x3 retries? Mind you I am calling a function that puts the server reply in a channel and I check the channel.

urbanslug08:05:27

Should I recurse on the channel making function only? or the whole function?

urbanslug08:05:25

I saw from the good parts that atoms are dangerous

jrychter08:05:53

@bojan.matic: I realize this isn't much help, but ā€” consider whether you really want to do that. After considering carefully, I always found that the components I found online weren't worth using. It was always quicker, easier and more future-proof to rewrite them using Rum/Om/Reagent/whatever.

bojan.matic08:05:35

@jrychter: i want to make an image cropper, i never really did that, and Iā€™m not sure about the complexities involved

bojan.matic08:05:46

there are quite a few already working react components for that

jrychter08:05:58

I never had anything that complex. In my case it was UI components, tables, etc ā€” which also had large interfacing area. Your case seems to be different.

bojan.matic08:05:10

yes, for less complex things I wouldnā€™t bother either

bojan.matic08:05:22

but this sounds possibly hairy, thatā€™s why iā€™m asking

jrychter08:05:57

I'm looking for advice on how to dynamically load an additional JavaScript library (to be specific: braintree.js for payments). I thought about dynamically adding <script> tags, but then I considered ā€” if I modularize my ClojureScript app, is there a chance that if only one module requires the library, it will only be in the generated JavaScript for that module?

jrychter08:05:59

Also, the docs say: > This file is distributed as a UMD bundle to support a variety of module systems. This means you can use tools like Browserify, Webpack, or Require.js to include it in your project I am not sure whether this means anything wrt ClojureScript.

iwankaramazow10:05:19

@jrychter: google closure compiler offers you excellent dynamic code splitting/dynamic loading of modules at runtime

iwankaramazow10:05:25

this blog post isn't specific to your exact problem, but it'll get you starting

jrychter10:05:06

@iwankaramazow: I was just reading the ClojureScript wikiā€¦ thanks for that link, it's very useful and I didn't find it yet!

jrychter10:05:41

In general, this looks complex. I guess I'll just take on the additional 176kB and save modularizing for later.

iwankaramazow10:05:37

Yea, took me a while to figure it out. The question is: do you really need it? The guys from React-Router are promoting dynamic loading of modules at runtime, but honestly... if you really need the performance boost, this is just a tiny bit of the solution

jrychter10:05:25

Well, I have my app, which is already fairly large (1.4MB or so), and I've just increased its size by roughly 200kB just by adding braintree.js. This code is used only in the signup credit card processing page. It seems ridiculous to take on this code increase. On the other hand, splitting the app into modules is much more complex than I thought and will likely take several days of mostly trial-and-error work. I guess I need to get back to the hacky idea of just inserting a <script> tag.

iwankaramazow10:05:39

project deadline approaching?

jrychter10:05:05

Code size is a problem ā€” I'm already worried that people who click "instant demo" on the homepage have to wait for 1.4MB of JavaScript, which then has to be parsed and processed. I will have to deal with modularization eventually, if only to implement progressive loading. For the moment I use a prefetch hint to at least ameliorate things.

jrychter10:05:27

No, no deadline, just a single entrepreneur. You have to be very careful where you invest your time.

iwankaramazow10:05:47

server side rendering?

jrychter10:05:07

Not for now, don't need it.

jrychter10:05:11

But in projects where I do, it's something that Rum started doing very nicely and cleanly. In this project I'm not sure if it's a good way to solve this problem.

risto11:05:49

How can I get the clojurescript go macro to work in this example:

risto11:05:09

I'm not sure why this isn't working, the compiler isn't providing any clues

dnolen12:05:55

@risto need more information than ā€œisnā€™t working"

dnolen12:05:21

what errors, behavior are you seeing?

risto12:05:53

@dnolen: No errors, it just isn't printing the result

risto12:05:53

But if I run the GET command without the wrapper to turn it into a core.async style thing, it will print the result

dnolen12:05:56

@risto might be useful to paste the thing that works for comparison

risto12:05:00

It prints the result to the console:

{"id" 1, "name" "Leanne Graham", "username" "Bret", "email" "", "address" {"street" "Kulas Light", "suite" "Apt. 556", "city" "Gwenborough", "zipcode" "92998-3874", "geo" {"lat" "-37.3159", "lng" "81.1496"}}, "phone" "1-770-736-8031 x56442", "website" "", "company" {"name" "Romaguera-Crona", "catchPhrase" "Multi-layered client-server neural-net", "bs" "harness real-time e-markets"}}

risto13:05:21

The package that's exposing ajax.core is cljs.ajax. All I did was create a figwheel leiningen template and added the above to core.cljs

fasiha13:05:50

@risto you have a typo: (GET url {:hander handler :error-handler handler})

fasiha13:05:59

s/hander/handler/

risto14:05:32

@fasiha: Omg, thanks for spotting that

risto14:05:48

I shouldn't be coding at 4am (face-palm)

risto14:05:42

Though generally I'm wondering, wouldn't it be fairly straightforward to write a library that can convert async callbacks into the core.async style?

risto14:05:20

I'm thinking of doing something like that which you could use for different Promise specs, listener style callbacks, regular callbacks, etc

sbmitchell14:05:01

thanks @juhoteperi you are on you on top of the cljsjs repo simple_smile

sbmitchell14:05:33

mistyped..but you get the drift hah

juhoteperi14:05:53

@sbmitchell: simple_smile Do you want commits rights to the repo?

sbmitchell14:05:34

That would be cool.

kauko14:05:45

Hi! I'm working on a demo application that uses Rum I plan on showing to some js devs, but I'm having second thoughts about this. Cursive still has really poor support for macros, which unfortunately makes working with Rum pretty ugly.. it doesn't really bother me that much, but it will probably be a pretty bad first impression to the attendees. I'm thinking of adding a /reagent route that will mount reagent components, and a /rum route that will mount rum components. Just wanted to make sure that makes sense.. React won't blow up or anything, right? šŸ˜„

kauko14:05:57

Don't want to waste my time if the idea is doomed from the start

sbmitchell14:05:45

I would think that would be perfectly doable

sbmitchell14:05:57

it all compiles down to the same stuff šŸ˜›

kauko15:05:12

Yeah. I'd imagine having them both on the same page wouldn't work, but on different pages, don't see why not

sbmitchell15:05:14

if they use the same react version and compile to native react components you could probably use them on the same page...not sure about rum's interaction with native react but reagent has helpers to build a native react component. I would then assume you could nest it as a child in a rum component šŸ˜œ

kauko15:05:36

sounds... not worth it to be honest šŸ˜„

sbmitchell15:05:42

agreed just saying its possible hah

sbmitchell15:05:29

that would be the equiv of using ember + angular in the same project

ericfode17:05:41

So i am working with cljsjs/js-yaml and when i enable advanced compilation it seems to eat the jsyaml symbol https://github.com/cljsjs/packages/blob/master/js-yaml/resources/cljsjs/js-yaml/common/js-yaml.ext.js and i am not sure how to fix it

ericfode17:05:01

If anyone knows I would be happy to make a pr to fix itā€¦ Iā€™m just mystified

xcthulhu17:05:13

You can compile externs with this thing:

sbmitchell17:05:53

You can use this one as well

xcthulhu17:05:51

Anyway, if I was going to write this by hand I would do var jsyaml = {load: function(){}, ...};

ericfode17:05:33

I am a bit of a noob when it comes to js and gclosure, why does writing it like that work better?

ericfode17:05:37

(also thank you)

xcthulhu17:05:01

TBH it's a google closure compiler thing.

xcthulhu17:05:28

It's a confusing system, I honestly never really know if my externs are okay. I recently wrote a bunch for the Stanford JavaScript Cryptography Library and I had to lean on its unit tests to know if I was doing things correctly.

xcthulhu17:05:41

jsyaml is a commonjs library, so might try compiling with your extern file using the google closure compiler and phantomjs to make sure you're exposing the right things.

xcthulhu17:05:53

The source code for the closure compiler isn't much help either, btw. They actually have an extern generator in there, they don't expose it at the CLI (but apparently the google internal version of the closure compiler exposes it)

ericfode17:05:12

Gotta love open source ā¤ļø mysteries abound!

cfleming18:05:25

@kauko: When is your demo? Iā€™m hoping to improve macro support shortly, depending on whatā€™s required - Iā€™m not familiar with Rum.

nkraft19:05:32

I do a lot of work in Clojure, but I'm just getting into Clojurescript. Anyone want to recommend a good lein-based intro for someone with a Clojure, Java and JavaScript background?

fasiha19:05:34

@nkraft: I really enjoyed https://github.com/bhauman/lein-figwheel/wiki/Quick-Start to get up and running with figwheel+react with a minimum of magic. Helped me learn both cljs & react. (Then I loved reading the re-frame readme but that might be an acquired taste.)

pleasetrythisathome19:05:02

has anyone ever seen the following error in advanced compilation?

pleasetrythisathome19:05:04

regressing to 1.8.40 fixes the issue

nkraft20:05:30

@fasiha Thanks. That looks like a good resource!

zentrope21:05:55

With 5.3 of figwheel, I get a ā€œWebSocket network errorā€. How do I debug what it thinks itā€™s trying to connect to?

zentrope21:05:07

I get a connection refused (though my regular websocket works), but canā€™t see anywhere a place to see what Figwheel things itā€™s using.

zentrope21:05:27

Huh. If I explicitly set my host name ā€œfoo.localā€, Figwheel doesnā€™t work. ā€œlocalhostā€ works, though.

zentrope21:05:18

:server-ip and :server-hostname donā€™t work. Only ā€œlocalhostā€.

zentrope21:05:20

Explicitly setting :server-ip to ā€œ0.0.0.0ā€ on the server-side seems to have solved the problem.

lwhorton22:05:09

I wonder, if weā€™re getting much better performance from transit-cljs versus json-parse + js->clj, does running the parsed to keywordize the keys again negate any benefit? I dont want to use strings as map keys - that sucks. (source : http://swannodette.github.io/2014/07/26/transit--clojurescript/)

jr22:05:21

there is a destructure syntax for string keys

(let [{:strs [foo]} {ā€œfooā€ ā€œbarā€}]
  foo)
=> ā€œbarā€

sbmitchell23:05:48

Yea thats quite useful when working with js lib callbacks simple_smile

sbmitchell23:05:29

What is the best way to get a nested prop out of a js object in cljs and be able to work in advanced compilation?

sbmitchell23:05:57

I know this works...`(aget (aget (aget @world "objects") "countries") "geometries")` and this did not (-> @world .-objects .-countries .-geometries) work in advanced compilation. Obviously I want a cleaner way than those aget's

sbmitchell23:05:25

the latter does work in simple and none optimizations