Fork me on GitHub
#clojurescript
<
2015-10-07
>
tel00:10:41

@bhauman: Is it intended behavior that if a file gets reloaded but hasn’t changed that the macros don’t re-run? I’ve got a sort of unfortunate macro which reads a resource file and it’d be nice if I didn’t have to keep touching the file that calls it to make a reload occur simple_smile

tel00:10:10

Actually, what would be best is if I could indicate that a file has a non-obvious dependency that needs to be watched too

tel00:10:45

(ns ^{:figwheel-load #{“resources/i18n/*”}} …) would be really cool 😉

tel00:10:06

@dnolen: what was the use case?

dnolen00:10:40

when we boot up we index all the queries components have to declared

dnolen00:10:04

for simplicity reasons we actually preserve the query from the root of the application

dnolen00:10:29

this has lots of benefits - you can apply local state transformations on the way down to update the component

dnolen00:10:59

(avoiding the Flux event driven derived store madness)

dnolen00:10:11

but the problem is that components can change their queries

dnolen00:10:23

and a components query is somewhere at the bottom

tel00:10:25

preserve the query from the root of the application? (sorry, side topic I guess)

dnolen00:10:00

you need to know every transformation on the way to the component

dnolen00:10:12

there’s no way to do this without preserving all the step from the root of the query

dnolen00:10:40

[{:todo/items [:by/id :todo/title]}]

tel00:10:41

ah, ah, I see, as state is passed down it keeps getting transformed and you’re registering these changes at the top

dnolen00:10:09

even if you intend to only update a single todo you will often want to pass through :todo/items part of the router (called parser in Om Next)

dnolen00:10:26

this is because you want some merged view of whatever the server gave you and whatever other local info you need

dnolen00:10:34

conceptually this is what derived stores in Flux try to do

dnolen00:10:25

you see people do this in components sometimes and in general want to avoid that unless necessary

dnolen00:10:36

in anycase, the problem is that a component can update it’s query

dnolen00:10:07

so instead of storing the actual query we store a zipper of the query where the zipper is paused on the last step

dnolen00:10:30

if a query changes we can functionally use this zipper template to get the new query

dnolen00:10:02

and because queries are never really big enough to be interesting this is a very clean solution w/ no performance impact of interest

dnolen00:10:21

the times they are a’changin'

tel00:10:59

gotcha, cool! that is definitely a good use case—being poised at the tip of a data structure, ready to modify

tel00:10:21

I always talk about them as being (data-structure, path) pairs with better performance characteristics

tel00:10:33

so you kind of need that performance question

dnolen00:10:35

just got declarative query updating working in Om … it is sick! 😄

sjol00:10:35

odd question but here it goes: is there any recommended way to integrate clojurescript (om/react) code into an existing JS/react codebase cleanly?

lfn300:10:49

@sjol you can use regular js react components inside om. Not sure if that’s what you’re after though?

sjol00:10:19

no I want to use my OM/Reagent code from the JS codebase

dnolen00:10:48

@sjol it’s possible but that’s the direction where it’s more challenging, especially if you’re tied to JS tooling.

lfn300:10:35

Might be easiest to just let om mount inside it’s own app root and handle all it’s own stuff, if you can? I don’t think you’d realise a lot of the benefits of om or reagent by just writing components in cljs.

dnolen01:10:12

and Om Next time travel works even if you change queries … can’t do that in Relay 😄

dnolen01:10:40

that is queries are automatically associated with an application state, if you got back those queries modifications will reapply

bhagany01:10:12

that is awesome

sjol01:10:57

@lfn3: thanks, the goals was not to have to rewrite code that was already done in clojurescript to react, but I may have to do so

lfn301:10:07

@sjol: You might be able to reuse them, but it’ll depend on how much they depend on being passed or having access to global cljs primitives.

dnolen01:10:25

please do not edit, ask me questions here or suggest enhancements via issues

shaun-mahood01:10:56

@dnolen: congrats on getting things this far. Part way through reading, the reconciler is a very cool idea.

shaun-mahood02:10:20

The rest of it is also very awesome. Looks a lot easier to understand than om with cursors, at least to me. I'm looking forward to seeing what people can do with it.

dnolen02:10:35

@shaun-mahood: yeah been wanting kill of cursors for a long time. But really that's the tip of an iceberg :)

dnolen03:10:07

ooh! Cursive update has community ClojureScript logo for .cljs files!

cfleming03:10:39

Sadly no pretty icon for CLJC or EDN yet

dimovich08:10:09

Hello All! I've been running through the cljs quickstart guide... On windows everything runs as expected. But on Ubuntu whenever I try "java -cp cljs.jar:src clojure.main repl.clj" I get "java.lang.RuntimeException: No such var: cljs.build.api/build"

sander09:10:04

dimovich: what .clj script are you using?

fdserr09:10:58

@dnolen could not find even a typo 😃

mcgivernsa09:10:01

this is one typo I found, going to actually work through it later

mcgivernsa09:10:12

> For example to getting a todo list might look something like the following

bbss13:10:40

@dnolen: Following the om next quickstart, Where [org.omcljs/om "0.9.0-SNAPSHOT"] gave a "was not found" in clojars with some notification about http proxy settings so I changed that to 0.9.0. I live in Shanghai so initially I thought it might have been the Chinese firewall at it again.

bbss13:10:56

Now onwards to the next part! simple_smile

dnolen13:10:15

@bbss make a checkout of Om repo, lein install it

bbss13:10:02

Oh, is that how those snapshots work? Thanks

ivern13:10:09

@dnolen The 'Your first component' section of the getting started guide for om-next mentions creating src/om_tutorial/core.cljs, a step the user's already done about one page prior in the 'Checkpoint' section.

dnolen13:10:24

@ivern: thanks fixed

ivern13:10:03

@dnolen misspelled 'documentation' at ' Note: For a more detailed list of React methods that components may implement please refer to the React documetation'

dnolen13:10:29

@ivern cool thanks, if you have more feedback there’s an Om channel simple_smile

dnolen13:10:32

#C06DT2YSY

ivern13:10:37

Oops, sorry.

ivern13:10:41

I'll join that.

martinklepsch13:10:06

@dnolen: great writeup! In one place find is used where get would seem simpler but other than that 👍

dnolen13:10:45

surprisingly similar to Falcor docs and the developing Om Next ones 😉

jeremyraines15:10:24

how can I make it return the width and height values that are only available once the Image element's onload fires?

dnolen16:10:55

@cfleming: last Cursive seems to be acting weirdly, eating up all my cores to run simple REPL commands

bmaddy16:10:39

Has anyone had any luck getting uberjars working with clojurescript? I keep getting Uncaught ReferenceError: goog is not defined in the browser with :optimizations :none and more cryptic errors with :optimizations :advanced.

bmaddy16:10:19

Here's my project.clj if anyone has a minute to take a look: https://gist.github.com/bmaddy/3109b23181afba0b13ba

martinklepsch16:10:07

@jeremyraines: are you asking how to do it in a synchronous way or what exactly are you having problems with?

jeremyraines16:10:11

yeah. Or async would be fine, but could use a little guidance there, especially b/c I'm not sure I want to pull in core.async just for this case

dnolen16:10:54

@bmaddy: making an uberjar with :none is not something I would pursue. Does your project build correctly with :advanced (ignoring uberjar for now)

bmaddy16:10:50

Good to know, thanks. I'll try with :advanced, one sec.

martinklepsch16:10:18

@jeremyraines: There’s plenty of async stuff in closurelib that might be worth checking, also you can just swap things into an atom and add a watch, really depends on what’s already there and how complex things are (going to become)

jeremyraines16:10:46

ok, thank you. Any idea of how to make it be or seem synchronous? Something like a future maybe?

dnolen16:10:40

@jeremyraines: there is no way to do that

dnolen16:10:51

this is what core.async is for

jeremyraines16:10:09

I'll go with that then

dnolen16:10:26

@jeremyraines: but if all you’re doing is this image thing that’s probably overkill

dnolen16:10:29

just write a callback

bmaddy16:10:28

@dnolen: I can't seem to get advanced mode to happen--I changed all instances of :optimizations to :advanced, but when I look at the served javascript it isn't minified. I started the app in the repl (`(run)`) and also tried lein run (after adding a :main vk-loop-player.server to my project.clj) with no luck. Am I missing something silly here?

dnolen16:10:52

@bmaddy it’s really hard for me to say - I do not use lein profiles somebody else will have to chime in

dnolen16:10:11

but a quick overview doesn’t show me anything obvious

bmaddy16:10:26

Ok, I'll keep looking at it. Maybe I'll try removing the profiles. I appreciate your willingness to take a look--thanks!

bensu17:10:29

Hey @bmaddy try to get the :advanced stuff running before packing it in an uberjar

bensu17:10:44

also, what is your apps starting point? is it under env/dev/cljs?

bmaddy18:10:10

@bensu: The file is env/dev/cljs/vk_loop_player/main.cljs. Thanks for taking a look at this.

bmaddy18:10:30

Or maybe you wanted the contents of the file: https://gist.github.com/bmaddy/c9e90bed22ac03938e7c

bensu18:10:09

first, I would remove all react preambles, reagent should cover this. (if that version doesn't, just use a newer version!)

bensu18:10:25

that main.cljs looks good for development

bensu18:10:09

@bmaddy: for :optimizations :advanced you will probably want to have one that is exactly the same, without the figwheel/weasel references

bensu18:10:22

(just (core/main))

danielcompton18:10:24

In a mixed CLJ/CLJS project, is there any effect on CLJS compile time if I add more CLJ dependencies?

bmaddy18:10:42

Yeah, my env/prod/cljs/vk_loop_player/main.cljs file is exactly as you describe. It also omits the [cljs.core.async :refer [put!]] line. I'm trying now without the preamble stuff.

dnolen18:10:48

@danielcompton: there should not be

bmaddy19:10:08

@bensu: when I remove the preamble stuff the app still compiles and runs just fine, but when I view the loaded .js files in the browser they look like normal javascript, not minified (i.e. I still see function names, lots of newlines, etc.).

jeremyraines19:10:24

I'm trying to drag my brain out of promise-thinking; could someone point me to a resource or example with core.async for doing something like Q.all() in js? Example: I have a a collection of maps, which must each be updated asynchronously, and only once all updates are complete, do the next thing

danielcompton19:10:49

@jeremyraines: do you need to use the results of the changes as well?

jeremyraines19:10:06

Yeah. I want to do something with the "updated" collection

danielcompton19:10:46

@jeremyraines: do you have a current code sample you can share?

jeremyraines19:10:26

I don't right now because I'm away from my computer, but could in like 40 mins. Sorry. There's not much there though except the synchronous version and me setting the most basic core async loop & channel

danielcompton19:10:17

if you share the sync version we can probably make it async simple_smile Also, you might want to try putting it in #C05423W6H as the people there love a challenge

jeremyraines19:10:03

Ok, will do, thanks

hugobessaa20:10:42

do you guys recommend any Getting Started guide to testing ClojureScript?

hugobessaa20:10:16

specially making it work with Lein

miguelb20:10:06

I’ve seen a lot of information on using javascript libraries in clojurescript and almost nothing on using the compiled clojurescript bundle from javascript (maybe I’ve been searching for the wrong terms…). For example if I wanted to write a Flux store in clojurescript is there way I could use the resulting bundle and import it in my app?

hugobessaa20:10:44

@dnolen mies could come with tests already. what do you think?

dnolen20:10:46

@hugobessaa: I don’t really work on mies anymore

dnolen20:10:48

@miguelb: taking something you wrote in CLJS in JS is not really that popular of a way to go if you’re not talking about Node.js, ClojureScript stuff starts around 20K gzipped and goes up from there

miguelb20:10:32

@dnolen: that’s unfortunate. I work on a small team and they’re bit wary of me introducing cljs. I figured start with a fairly complicated piece the app we’re working on and have it be transparent and slowly start replacing parts simple_smile

dnolen20:10:42

@miguelb: it’s just not a supported use case and is unlikely to be. It’s definitely one of the nicer things about compile JavaScript languages with narrower scope like CoffeeScript et al.

bhagany20:10:23

@miguelb: I've been thinking about doing something similar. There are leaves in any dependency graph - I'm planning on starting there and moving up.

miguelb20:10:02

got the idea from post on Elm where they started porting over their stores to Elm while keeping the origin js app intact

dnolen20:10:28

@miguelb: note this is mostly a problem for JavaScript code bases that use the large and diverse ecosystem of JS tooling.

dnolen20:10:40

in ClojureScript we use only Google Closure

dnolen20:10:56

if your JS code base was Google Closure based what you’re talking about would be pretty trivial

miguelb20:10:39

worth considering

dnolen20:10:55

@miguelb: I think it’s big deterrent for a lot of JS people since it’s not a very hip thing that people talk about. Thus you see ClojureScript adopting JS stuff all the time, but hardly the other way around.

martinklepsch20:10:12

I’m confused by what’s said here. Isn’t what @miguelb is asking for similar to how mori is implemented?

cfleming21:10:25

@dnolen: Weird, just sending forms to the REPL?

dnolen21:10:51

@cfleming: yeah can’t repro on work machine

cfleming21:10:23

@dnolen: Weird, no-one else has reported anything. Let me know if it keeps happening on your home machine and I’ll take a look.

settinghead22:10:53

I’m thinking of writing a Meteor package that enables Meteor to compile cljs into JavaScript on the fly. someone has done a version that basically uses Leiningen to do the compilation: https://atmospherejs.com/mystor/clojurescript. My question is: with the new clojurescript compiler for clojurescript, is it possible to get rid of the Leiningen dependency?

settinghead22:10:16

is that possible (or at least in theory) at this stage?

maria23:10:01

@settinghead: I am not very familiar with Meteor, but it is possible to use the ClojureScript compiler without leiningen. The Quick Start tutorial doesn't use leiningen and only requires you to download a standalone ClojureScript JAR. https://github.com/clojure/clojurescript/wiki/Quick-Start

settinghead23:10:16

@maria thanks. i think that should work better than Leiningen. simple_smile however, was thinking more along the lines of completely getting rid of JVM, like starting the compilation process in node (which is what Meteor is based on), compile cljs in node and output js. if i could achieve that it would be awesome, because you could then just use it as a regular Meteor package without external dependencies like JVM.

maria23:10:45

@settinghead: well, there is bootstrapped ClojureScript, which lets you compile ClojureScript to JavaScript without the JVM. https://github.com/clojure/clojurescript/wiki/Bootstrapping-the-Compiler

settinghead23:10:35

cool. i saw it. just wasn’t sure if there are any limitations

maria23:10:39

You would initially need to write a ClojureScript project which uses the cljs.js namespace and then compile it using the JVM, which would then give you JavaScript that allows you to compile cljs to js.

maria23:10:10

Similar to this project here from dnolen https://github.com/swannodette/cljs-bootstrap

settinghead23:10:25

ok. i’ll give it a try!

settinghead23:10:25

we have been using mori.js for one of our Meteor projects and we loved it. thought would be nice to have more cljs integration into Meteor ecosystem

maria23:10:49

there are always people here who are happy to help if you have any questions 😉