Fork me on GitHub
#clojurescript
<
2016-09-30
>
shdzzl01:09:01

Was going over the guides for Om Next, and there's a section of code that I can't seem to work out.

(defn get-people [state key]
  (let [st @state]
    (into [] (map #(get-in st %)) (get st key))))
On this page here: https://github.com/omcljs/om/wiki/Components%2C-Identity-%26-Normalization#appendix What is the transducer being passed to into trying to achieve there?

andre03:09:52

hi! is it any correct way to pass cljs data between two windows? now i can do it, i can print it, it looks good, i can deref atom, but i can't get value from map by keyword

danielcompton04:09:00

@andre interesting question. is it possible that keywords from different JS contexts will have different values?

danielcompton04:09:08

what happens with string keys?

andre04:09:46

i didn't try string keys

andre04:09:27

had the same thoughts about keywords context

andre04:09:00

also i'm using reagent for rendering this passed data, and reagent doesn't rerender it, something wrong with this data

andre04:09:56

passing this data as edn? i don't think this is a good idea

dnolen11:09:08

@andre there’s no support for cross context JS - it just not worth the trouble

andre11:09:53

@dnolen ok, thank you, сan you advise something to "serialize" data between contexts? data->edn (json?)->data ?

danielcompton11:09:19

Transit is probably best option here

andre11:09:49

thank you, i'll look

dnolen11:09:01

@andre depending on how much data, yes EDN could work - Transit will be a bit faster.

tianshu13:09:35

I think lein-externs provide a very simple approach for generating externs file, why not cljs-build or cljs-compiler use it by default?

dnolen13:09:26

@doglooksgood: because we don’t integrate anything around Leiningen

dnolen13:09:53

it could be that lein-externs works reasonably well but it doesn’t have enough users to appear to be properly vetted for integratino into any other tooling

tianshu13:09:54

I mean this plugin just use some regex to find which name should be preserve. It's quite simple.

dnolen13:09:26

which isn’t going to work when a JS library programmatically generates names

dnolen13:09:49

which isn’t exactly uncommon given the lack of more static forms of metaprogramming in JavaScript

tianshu13:09:02

I've found your talk for next 5 years for ClojureScript. You mentioned about externs

tianshu13:09:08

Hope one day we don't need to generate externs manually. 🙂

dnolen13:09:21

yes eventually

kenbier17:09:09

did anyone have issues updating from clojurescript 1.8.40 to 1.8.51 or later? Its the point where the closure-compiler is upgraded to v20160315 (if thats related I’m not sure). My dev app works, and advanced compilation builds without error, but in advanced comp my app does not even mount. Not sure where to start debugging 😕

kenbier17:09:01

i am also on om 1.0.0-alpha44

dnolen18:09:27

nobody reported anything like that that I can recall

dnolen18:09:42

@kenbier is there any reason to not just bump to 1.9.229?

dnolen18:09:13

there might be some Om changes that are the problem

kenbier18:09:38

@dnolen i see, ok. i tried bumping to 1.9.229 as well but i saw the same issue. every version before 1.8.51 seems to work.

dnolen18:09:15

@kenbier then need way more information

dnolen18:09:21

so far we have none 🙂

dnolen18:09:30

“not working” is not information

kenbier18:09:40

haha yeah i agree.

kenbier18:09:57

is there anything that would be helpful to know?

kenbier18:09:45

currently using clojurescript 1.8.40, clojure 1.8, om alpha44, and i had to exclude guava from datomic “0.9.5344” because it was colliding with the google-closure version

kenbier18:09:22

im in the middle of trying to update our core dependencies. we were on om 1.0.0-alpha36 and clojurescript 1.7.228. I was able to upgrade om to alpha 44 and clojurescript to 1.8.40. if i upgrade to 1.8.51, and exclude guava from datomic, i get a build with no errors. but when i load my app, the “app” div is just an empty div. no console errors, build errors or network errors. the outputted js is there as well.

kenbier18:09:45

i realize thats not enough information but thats where i am right now in debugging. before i went deeper i wanted to check if moving to a new google-closure version broke some peoples build, which it does not sound like it did. so ill do some more research

kenbier18:09:50

thanks for the help

dnolen18:09:40

@kenbier yeah that’s just not enough information

dnolen18:09:08

@kenbier a couple of tips, make a advanced build with prettying printing and pseudo-names enabled

dnolen18:09:10

set some breakpoints

dnolen18:09:23

:pretty-print true :pseudo-names true

kenbier18:09:45

@dnolen ill try that now. thanks!

owen19:09:59

has anyone found / written any good resources on using spec with figwheel? my thinking was placing the cljs.spec.test/instrument calls in the :figwheel-on-js-load function but it does not seem to instrument fns, my guess is somehow they are getting overwritten after instrumentation by something in figwheel

owen19:09:06

I also have not been able to Google anyone having similar issues

kenny20:09:16

If I have core.cljs and core.clj, is it possible to use the macros in core.clj in core.cljs? Just trying to directly call my macros, without adding anything to my :require, results in WARNING: Can't take value of macro

kenny20:09:40

It seems like the above is possible according to this https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#macros > ClojureScript namespaces can require macros from the selfsame namespace, so long as they are kept in different compilation stages. So, for example a foo.cljs or foo.cljc file can make use of a foo.cljc or foo.clj file for its macros.

kenny20:09:15

Duh, you have to add :require-macros for your namespace.

dnolen20:09:05

@owen instrument needs to be called after your fdefs

owen20:09:27

Im able to get instrumenting working

owen20:09:33

my goal is to have it in the /dev classpath

owen20:09:05

so I dont have to manually eval the instrument calls, and it will be elided in the uberjar cljsbuilds

dnolen20:09:20

@ownwaterloo note instrument isn’t a runtime thing

dnolen20:09:31

it’s not the traditional notion of “after” here

dnolen20:09:40

I mean after the compiler has seen all your fdef files

owen20:09:32

if I had the :figwheel-on-js-load call a fn (do (fdef things.....) (stest/instrument 'fdef-ed-fn))

owen20:09:40

would you not expect that to work?

dnolen20:09:09

depends, I don’t know how that figwheel thing works

owen20:09:20

I assume you have some experience with what it does

dnolen20:09:34

I never use that, so no

owen20:09:42

oh my bad, it will do hot code reloading

owen20:09:04

so om or reagent will get revalued after file changes

dnolen20:09:06

but remember

dnolen20:09:15

fdef instrument are static

dnolen20:09:26

if Fighweel isn’t recompiling that expression everytime, it isn’t going to work

owen20:09:49

sorry yeah the :figwheel-on-js-load is a setting in project.clj which will call a function when it detects file changes

owen20:09:59

so that function should be getting called on every change

dnolen20:09:04

you’re missing what I’m saying

owen20:09:05

but my guess is its happening in the wrong order

dnolen20:09:21

calling a function isn’t going to help you

dnolen20:09:31

recompiling the function every time is going to help you

dnolen20:09:39

but I doubt it works that way

dnolen20:09:06

it’s probably far simpler to just have a dev namespace

dnolen20:09:28

which requires everything you need that has s/instrument

dnolen20:09:14

:recompile-dependents true would allow you to edit other files and trigger this dev namespace to recompile

dnolen20:09:20

pretty sure this compiler option is disabled by Figwheel

owen20:09:57

hmm ok that all makes sense

owen20:09:09

especially the necessity of compiling the spec fns

kenny20:09:47

Is there a reason https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/specs.clj is not included in cljs yet? Seems as simple as adding the namespace, no?

owen20:09:57

its in there?

owen20:09:07

cljs.spec

kenny20:09:18

No, specs.clj

kenny20:09:25

Not spec 🙂

dnolen20:09:36

@kenny not in because it doesn't work for CLJS

owen20:09:37

man my reading comprehension today

dnolen20:09:54

some of those specs are OK, some aren't

dnolen20:09:20

specifically ns form stuff isn’t going to work

kenny20:09:14

Right. You can’t partially add the file - only the working specs?

dnolen21:09:27

yep, we’ll add them eventually - porting clojure.spec is high priority

kenny23:09:48

How do you call var in cljs? I get a java.lang.AssertionError: Assert failed: (ana/ast? sym) when trying to call var.

kenny23:09:08

Even stranger.. I am able to call var in the REPL. Are you not able to have dynamic calls to var?

anmonteiro23:09:45

@kenny vars in ClojureScript are static

anmonteiro23:09:59

you shouldn’t expect them to work like in Clojure

anmonteiro23:09:22

AFAIK their implementation is minimal enough for cljs.test to work

kenny23:09:51

@anmonteiro You aren’t able to dynamically retrieve metadata from a symbol then? 😞

anmonteiro23:09:20

for a symbol that refers to a var?

anmonteiro23:09:39

maybe with some macro black magic, I’m not sure

kenny23:09:47

I attach metadata to a function and I want to retrieve that at runtime

anmonteiro23:09:19

which would be calling cljs.analyzer.api/resolve in the Clojure side of things

kenny23:09:23

It wouldn’t be able to resolve cljs vars though, right?

anmonteiro23:09:44

it would, that’s what I’m telling you

kenny23:09:54

That might work then

anmonteiro23:09:10

you pass it the &env and the var symbol

anmonteiro23:09:56

but note that most your expectations regarding vars in ClojureScript won’t hold

anmonteiro23:09:17

they’re not going to work like in Clojure

kenny23:09:58

I was only hoping to get metadata off of them

kenny23:09:08

Why do I need &env?

anmonteiro23:09:19

&env is the ClojureScript compilation environment

anmonteiro23:09:26

it’s where the analyzer will find your var

anmonteiro23:09:20

then you need to think about how you’re going to return the metadata you find on the Clojure side to the ClojureScript runtime

anmonteiro23:09:53

probably worth more trouble than changing your implementation to something more solid

kenny23:09:49

I will reconsider my implementation

kenny23:09:03

How do you call the macro with &env?

anmonteiro23:09:24

&env is an implicit argument to the macro

anmonteiro23:09:33

it’s “there"

kenny23:09:47

REPL throws exception with wrong args passed to macro