Fork me on GitHub
#clojurescript
<
2016-02-02
>
jakemcc00:02:21

@danielcompton: you can setup a custom warning handler, example of one that turns warnings into errors here: http://jakemccrary.com/blog/2015/12/19/clojurescript-treat-warnings-as-errors/

ion02:02:19

I'm curious why http://todomvc.com/ doesn't link directly to an Om or Reagent implementation. Did I miss that? Anyone know why not?

ion02:02:47

Oh, I was looking for "ClojureScript"

ion02:02:18

I figured people would actually like to see something with ClojureScript in the name.

gadfly36106:02:21

@ion i put it under reagent to allow for Om and other libs to be added (and not steal the parent name of clojurescript for just reagent)

jaen06:02:05

Wouldn't Clojurescript + React (reagent) or something like that be better then?

jaen06:02:35

I didn't notice it at first, and even screen didn't help immediately. But then I may just be blind P ;

gadfly36106:02:09

I definitely think itd get more traffic with clojurescript in the name. As an aside, there is an open bug with chrome relating to that example. So if it looks like the example doesnt work... https://github.com/tastejs/todomvc/issues/1546

trancehime10:02:01

Anyone have any suggestion for a way to do js/setInterval and js/setTimeout in a Reagent webapp?

jaen10:02:24

What do you need it for?

jaen10:02:00

The simplest answer seems like doing a Form3 and creating it in the mount callback and removing in the unmount callback.

trancehime11:02:24

@jaen: I need to repeatedly call a function to check if two separate inputs on a server are the same.

jaen11:02:00

Is that component-specific or global for the application?

jaen11:02:25

Also should it be stoppable or not?

jaen11:02:42

(ie. it only stops when you close the page)

val_waeselynck11:02:32

@trancehime: this kind of machine may be easier to program if you have core.async

trancehime11:02:58

@jaen: It just occur on one view.

trancehime11:02:55

@val_waeselynck: Hmm... Would take me too much time to rewrite using core.async sadly, since I'm expected to pull something off in about an hour or so

jaen12:02:11

It wouldn't be hard with core.async, really, but if it only happens in one view, then just using a Form3 will be simpler

trancehime12:02:19

Form3 component it is?

jaen12:02:38

(defn thing-with-interval [callback interval]
  (let [interval-id (reagent/atom nil)]
    (reagent/create-class
      {:component-did-mount (fn [component]
                              (swap! interval-id #(js/setInterval callback interval)))
       :component-will-unmount (fn [component]
                                 (js/clearInterval @interval-id))}))

jaen12:02:51

Something like this could work, I suppose.

trancehime12:02:55

And I guess the callback is the function I want to do every interval.

trancehime12:02:06

Same concept if I want to use setTimeout?

jaen12:02:16

Yeah, though it'll fire only once.

jaen12:02:40

(also you can probably lose #(...) in that example and it'll probably still work; I did it that way because I was not 100% sure about semantics of js/whatever)

octahedrion13:02:26

anyone know how to declare multiple values for the same attribute in Garden ?

jaredly15:02:30

@jaen If you want to lose the #(), then you’d need to use (reset!

peeja16:02:50

Is there ClojureScript documentation somewhere, in the style of the Clojure docs, function-by-function?

peeja16:02:08

Most of it is the same, but there are a few differences, and I'm not sure where they're best documented

peeja16:02:32

For instance, is there a documentation set that includes clj->js? I only know it from wiki pages and blog posts.

seriousbug16:02:15

Zeal has support for cljs too, if you want offline docs

spinningtopsofdoom16:02:28

Really how do you import cljs docs in Zeal? I haven't been able to figure that out.

dnolen16:02:15

@peeja there’s been talk about getting at least Clojure style docs up somewhere

dnolen16:02:37

would requite a little bit of work to make Tom Falhauber’s autdoc work for CLJS - JIRA ticket for that

dnolen16:02:51

another low hanging fruit straightforward contribution

peeja16:02:09

Ah, awesome, good to know

pandeiro16:02:18

is anyone integrating datascript with reagent/re-frame? is it possible to 'outsource' part of the app state atom to a datascript instance?

rm17:02:42

pandeiro: yes, datascript is a data structure and you can put it anywhere you like

asolovyov17:02:18

anybody else notices slower re-compile times with .cljc? I'm not sure that's the problem, but I moved half of my codebase from .cljs to .cljc and compile times went from 0.3-0.5 to 5s...

richiardiandrea17:02:21

@peeja there is also http://clojurescript.io if you want to try your code right away as well (not all are documented in the main panel but doc works for the others) simple_smile

pandeiro17:02:10

@rm: I haven't used it, but I'm imagining filling it with some data and being able to update re-frame's app state db with the results of different queries, hopefully reactively so that when a certain query's results change, the app state db key would be updated

seriousbug17:02:24

@spinningtopsofdoom: I think you can download the latest docset from https://github.com/cljsinfo/cljs-api-docs/releases , and unzip it into ~/.local/share/Zeal/Zeal/docsets/

rm17:02:05

pandeiro: yes, it updates in views automagically jist like plain hashmap.

acron17:02:54

@octo221: did you get your garden issue sorted?

jthomson17:02:25

@pandeiro: you can definitely achieve something like that, but datascript queries are not themselves reactive. I.e. you’d have to re-run all your queries after each change to find out which ones changed. For simpler use-cases you can pattern match transactions (via listen!)

pandeiro17:02:24

much appreciated @jthomson -- still lacking fundamental understanding of datascript here simple_smile

conan17:02:18

this is more of a react question than a clojurescript question, but is there any reason i can't mount my entire reagent application into my <html> element? then i can mess about with tags in the <head> and stuff

pandeiro17:02:25

@conan: I'm curious if it works; can't think of any real reasons it wouldn't

jaen17:02:50

@jaredly: duh, of course; because swap! will pass the current value as the first argument and mess up the call. Thanks for being vigilant, lack of sleep doesn't do correctness any good : V

jaredly17:02:28

simple_smile I’m amazed how helpful you are at all hours of the day/night

jaen17:02:51

Compensating for lack of social life ;' ) But in all seriousness - why not help out if I can? I don't lose nothing on that, someone might gain some knowsledge (unless I mess something up like here), slack fulfils it's purpose.

grav18:02:38

anyone using atom+figwheel for cljs?

frank18:02:07

what's the proper way to use cljs.js/require?

jaen18:02:37

@frank: browser or node?

jaen18:02:51

Then there is none. It's a node thing.

frank18:02:26

😞 I'm trying to find a more clojurey substitute for js/goog.require

jaen18:02:52

If you need to use library the has CommonJS modules (or other kinds of modules) you need to use webpack/browserify/something else like that to compile the modules out and using the resulting file as a foreign lib.

jaen18:02:59

Unless that's not what you need it for?

frank18:02:12

I thought the node one was cljs.nodejs/require?

frank18:02:23

I need it to load a cljs namespace

jaen18:02:41

Duh; I shouldn't rethink giving advice when sleep deprived : |

frank18:02:36

unfortunately I don't think closure modules will help here 😕 I'm trying to write a macro that conditionally requires a namespace

frank18:02:05

so it would need to work similarly to using :require in the ns declaration

dnolen18:02:07

Closure compile times vs. popular JS combinations - not so bad

ericnormand18:02:43

can Om now render seqs of components?

ericnormand18:02:49

I remember it not working before

dnolen18:02:53

@ericnormand: there’s an #C06DT2YSY channel - and yes it can

yogthos18:02:41

it's happening simple_smile

shaun-mahood18:02:43

I'm traveling the next couple of days so I'll hopefully get a bunch of time to read it. Good timing!

asolovyov19:02:57

@dnolen: have you heard any reports that sizeable codebases in .cljc take much more time to compile than in .cljs? I'm not sure what's happening to my code...

elsehow19:02:41

does anyone know of a good resource for getting started with npm module / cljs interop?

dnolen19:02:58

@asolovyov: haven’t heard anything like that

dnolen19:02:08

@asolovyov: and would have seen that in self hosting anyways

dnolen19:02:26

self hosting compiles a good 15,000+ lines of ClojureScript including .cljc

asolovyov19:02:26

heh... any ideas how to diagnose what's happening then?

asolovyov19:02:49

I'm in the middle of converting my codebase to .cljc and incremental compile time is 5s now

dnolen19:02:13

since I don’t know what you are doing - I cannot form any hypotheses simple_smile

asolovyov19:02:35

hmm... well, I did to rum what this guy at clojure/conj did with foam, and now am converting my site to .cljc so I can render it server-side in clojure

dnolen19:02:10

I’m assuming there’s no Figwheel or anything else involved here?

asolovyov19:02:11

but... well, my compile time skyrocketed and it seems like it picks up more stuff to recompile than it needs to

venantius19:02:13

(“this guy at clojure/conj”)

asolovyov19:02:32

@dnolen: well, there is figwheel for the client side anyway

dnolen19:02:48

Figwheel has quite a bit of custom incremental logic

asolovyov19:02:48

and that's figwheel compile times right now...

venantius19:02:08

might be worth trying out a pure compilation process, as @dnolen seems to be suggesting

amrit19:02:12

hi new here.... can anyone tell me whats flux equivalent for reagent/clojure?

venantius19:02:15

to see if that’s the root of your issue

asolovyov19:02:18

hmm... yeah, I'll check that

dnolen19:02:44

@asolovyov: just make make a tiny build script only using the standard auto watch feature

dnolen19:02:48

touch a file and see what happens

asolovyov19:02:58

right, I'll be back in few minutes

asolovyov19:02:54

ok, it really seems like a figwheel problem

asolovyov19:02:17

without figwheel build times for master and my branch are +- the same

asolovyov19:02:32

thanks! I'll report that to Bruce then simple_smile

shaun-mahood19:02:49

@asolovyov: Are you planning to open source your foam-rum library at some point? Aside from the compile time, how's the rest of it going?

asolovyov19:02:14

you can even try it out for yourself by adding this to dependencies: https://clojars.org/ua.modnakasta/rum

shaun-mahood19:02:14

Really cool that it's just a PR. I'll have to take a look at it!

asolovyov19:02:14

@shaun-mahood: so far I'm quite happy, it seems I can generate html necessary for react to pick up on small apps and now I'm converting all my code so that I can validate idea against my main app

asolovyov19:02:02

the only thing that bothers me is that sizeable page generates html data structure in 0.8ms, but then my (hiccup-based) html renderer takes 20-40ms to convert that to a string 😕

asolovyov19:02:23

I've tried hiccup then (because I thought that maybe I failed something) and it turns out that it's slow like that... And it's fast only when it can pre-compile stuff with macros, so maybe that's the way to go... Ideally I see modifying sablono to render this stuff on the server should be the way to go. simple_smile Not sure if that will speed anything up though :))

shaun-mahood19:02:12

Does 40 ms make a big difference to your site? Seems like it's still pretty fast compared to most websites I visit.

slester19:02:03

Thanks so much for the stickers @chrisoakman!

asolovyov19:02:14

@shaun-mahood: well, I guess I can live with that! simple_smile 1) it'll still be faster than just rendering in the browser; 2) node.js rendering takes about the same; 3) if I skip user-related components on the server I can cache so hard it'll scream simple_smile

shaun-mahood19:02:31

@asolovyov: You should do a blog post (or talk) at some point on the real world application of it - seemed like a great idea but I'm not sure anyone else has put it into production on a large site yet.

asolovyov19:02:07

if (when) I release that to production I'll surely write a blog post

asolovyov19:02:30

and maybe a talk as well, but that depends simple_smile

shaun-mahood19:02:14

@asolovyov: Are you coming over for Clojure/West or the Conj again this year?

asolovyov20:02:21

@shaun-mahood: I don't know, it costs quite a bit of time and money for me to come there simple_smile So yeah, depends. I'll surely go to Polyconf, but I guess that will cost quite a bit of money for you simple_smile

asolovyov20:02:19

last year's trip was close to 2k$ in budget for a week in USA... I liked the experience but not sure I'll repeat this year

shaun-mahood20:02:14

Yeah it's definitely a long way for you - that's not that bad for cost though. Mine was about $1500 (flight, hotel and meals) for 5 days, so you must have gotten a pretty good deal.

asolovyov20:02:22

I did, actually. Flight was really cheap (a bit less than 500$), and hotel we've found was on some promotion, so yeah, it was very cheap simple_smile

shaun-mahood20:02:06

Crazy, you paid less for the flight than I did.

asolovyov20:02:32

😄 when I told my friends how much I've paid they practically murdered me, usually it costs ~800-900 if you're buying in advance. I don't know why it was that cheap, that was the reason I've came to clojure/conj though: couldn't skip when the flight is that cheap simple_smile

acron20:02:06

@octo221 whats the issue?

arohner20:02:21

shaun-mahood: I gave a talk about doing server-side rendering at the conj: https://www.youtube.com/watch?v=fICC26GGBpg

shaun-mahood21:02:18

@arohner: I was in the audience, it was really interesting! I'm hoping that at some point in the future it will become a fully baked part of Om.Next (or Om.Next.Next).

bbrinck21:02:33

I noticed that binding doesn't restore the values when used inside a go block.

bbrinck21:02:53

I don't fully understand if this is potentially a duplicate of http://dev.clojure.org/jira/browse/CLJS-884, or maybe a unique issue.

bbrinck21:02:55

I was trying to come up with a repro that does not involve core.async (as per the instructions at https://github.com/clojure/clojurescript/wiki/Reporting-Issues), but I am getting a little lost in the core.async macros.

bbrinck21:02:30

Does the above look like buggy behavior? Does it look like a dupe of 884?

dnolen21:02:41

@bbrinck: that ticket should probably be closed

dnolen21:02:03

using with-redefs with core.async doesn’t make a whole lot of sense to me - though I suppose it could be made to work

dnolen21:02:15

in anycase it’s not a ClojureScript issue, it’s a core.async one.

bbrinck21:02:56

Thank you, that's very helpful. I'll look into creating a bug for core.async.

puppybits21:02:05

@asolovyov: We’ve been working on that as well. Server renders the initial HTML for fast first paint and then the browser takes over rendering if/when react boots up. That allows for offline and every other page load is only 2k instead of 200k to send HTML. https://medium.com/@puppybits/letting-people-in-the-door-how-and-why-to-get-page-loads-under-2-seconds-340c487bd81d#f653

peeja22:02:05

Does ClojureScript not have promises?

grav22:02:13

@peeja - no. You can use javascript’s promises, or use a wrapper library such as promesa

jaen22:02:30

Or core.async.

jaen22:02:36

It can also work in that niche.

peeja22:02:55

Yeah, I thought about core.async but I don't think it'll make much sense here

peeja22:02:05

Is there a reason not to have them, or has it just not happened yet?

grav22:02:10

I guess you can’t have/shouldn’t have the same semantics, since you’re not supposed to block in javascript …

peeja22:02:20

Oh, fair enough

peeja22:02:33

I don't actually need to block in my case

jaen22:02:35

Yep, Clojurescript is light on the state/multithreading part due to differing semantics between JVM/JS VMs

peeja22:02:54

but it would be weird to have promises that couldn't block simple_smile

grav22:02:24

I think the javascript people would disagree with you there simple_smile

peeja22:02:36

Fair enough 😄

jaen22:02:50

@peeja: incidentally - using React? If so which wrapper? I imagine with reagent you could use a ratom for values that will be evaluated in the future.

peeja22:02:22

I'm using Om, but I'm also deep in our own custom architecture for data fetching

peeja22:02:55

I'm not even using promises in a reasonable way, really. I'm doing terrible things to avoid changing too much code yet simple_smile

jaen22:02:05

Ah, I see.