Fork me on GitHub
#clojurescript
<
2017-07-11
>
Lone Ranger03:07:43

anybody have any neat tricks for converting a state (`(def state (atom {}))`) to a url?

sundarj15:07:44

the url is a piece of state too, right? 'what route am i on?' is asking a question about the state of your application - ideally it would be in your state too imo

sundarj16:07:58

https://github.com/HenrikJoreteg/feather-app/blob/master/src/views/app.js something like this (havent found a cljs example of this yet)

Lone Ranger03:07:29

or, in general, declarative routing advice?

fabrao04:07:44

Hello all, why if I´m using figwheel and I load a javascript from index.html stop working after reload?

fabrao04:07:19

I have to reload the page again to working it back?

tap04:07:14

Do you mean javascript stop working after figwheel reload?

fabrao04:07:29

yes, I have a script that do ripple effect and it stop working after I save the cljs file

fabrao04:07:25

I tried to use breakpoint in browser, before reload it works, after reload it stops

tap04:07:18

Is there any error in the js console?

fabrao04:07:03

do I have to load it from foreing-libs?

fabrao04:07:51

I´m loading js lib direct from html file

tap04:07:18

If you don’t call the js lib from cljs, I don’t think you need to touch foreign-libs stuffs.

tap04:07:27

This is just my guess. I’m assuming you are using some kind of React wrapper. Is it possible that after figwheel reload, DOM is rerendered so js binding of the ripple effect is gone?

fabrao04:07:31

I´m using reagent, maybe js binding is gone. Is there any way to call load this .js from clojurescript?

fabrao04:07:48

to rebind it?

tap05:07:42

I’m not very confident about this. But may be you can use “js/…” like (js/console.log "message") (js/document.getElementById …)

tap05:07:30

Call this rebinding in an :on-jsload function that you specified in figwheel config

fabrao05:07:15

I´m calling it, but I think it will reload just the clojure stuffs, not the html js stuffs

shidima_06:07:37

Why when I save my data to sqlite does it turn a boolean to an int?

shidima_06:07:18

Ah, I see. Its a 'feature' of sqlite. SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true).

Avichal11:07:40

Spec is able to generate example data if I give spec as predicate vector? but it is not possible to get example data generated for predicate array?. I wanted it to generate js arrays. Any reason why it would be supported in spec ?

dnolen11:07:53

probably because generating mutable stuff is tricky / inefficient (requires cloning)

Avichal11:07:30

yes, makes sense. Thanks.

dnolen11:07:15

@avichalp that said you should be able to accomplish this with cljs.spec.alpha/with-gen, I think?

dnolen11:07:47

though you’d have to look into what is required for making an generator for arrays

Avichal11:07:55

@dnolen using fmap with clj->js on vector worked for me. Is it a good approach ?

dnolen11:07:51

@avichalp seems easy and safe to me 🙂

dnolen11:07:13

@avichalp also into-array if the array is not nested

dnolen13:07:54

@souenzzo if you want an enhancement open a new ticket and link to the old one please - for this issue please set minor priority - thanks

lxsameer15:07:31

@dnolen Hi, I was reading your post from yesterday about code splitting. I was wondering is there any way to do it dynamically ? I mean by just providing the entry point and compiler figure out the dependencies for that chunk ?

lxsameer15:07:45

Also kudos on new changes.

dnolen15:07:13

@lxsameer what do you mean by dynamically?

dnolen15:07:22

the whole point is to get a production build?

lxsameer15:07:49

@dnolen how should i provide the dependency list of a entry point ?

dnolen15:07:31

@lxsameer I don’t know what you mean?

dnolen15:07:39

you don’t need to provide it as the post says

dnolen15:07:47

the compiler knows

dnolen15:07:26

you never need to express deps - just entry points - the algorithm can assign everything else

dnolen15:07:45

(if this wasn’t clear I should update the post)

lxsameer15:07:24

Ow I get it now, good this i exactly what i was looking for

lwhorton15:07:45

if i find myself wanting a “default” implementation on a protocol, would that be a smell?

lwhorton15:07:28

i.e. i have two types that implement a protocol with some 3 functions… but 1 or 2 of those concrete implementations are identical

lxsameer15:07:52

@dnolen cool. this feature of clojurescript sits well with service workers . thanks man

martinklepsch16:07:59

@lxsameer a blogpost demonstrating use of this feature in combination with service workers would be super cool!

lxsameer16:07:45

@martinklepsch I'll definitely do that

roklenarcic17:07:39

It seems to work to a degree but it breaks figwheel reloading

roklenarcic17:07:01

figwheel reloads as normal, but the components don't render changes

roklenarcic17:07:50

I've also tried both React-Boostrap CLJS wrappers and they both use om-tools library, which doesn't compile (crashes with NullPointerException)

roklenarcic17:07:42

I am looking for a component library that would work for my om.next project and every single one I find is broken in some way

madvas17:07:30

@roklenarcic That library works pretty well for many people. Must be some little bug on your side 🙂

roklenarcic17:07:46

It works perfectly when I hit reload

roklenarcic17:07:11

but if I add a component or change a label it doesn't show up

roklenarcic17:07:20

until I hit reload

roklenarcic17:07:34

and my compiled folder .js file has the change

roklenarcic17:07:01

before introducing this lib, I used om.dom and figwheel worked perfectly with that

madvas17:07:22

Tried om.next with figwheel now on this https://github.com/madvas/cljs-react-material-ui-example reloads components well

roklenarcic17:07:00

btw I get this warning in console

roklenarcic17:07:01

Warning: Unknown prop onTouchTap on <button> tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop

roklenarcic17:07:10

I'll checkout your repo and try

madvas17:07:23

Make sure you exclude cljsjs/react and cljsjs/react-dom from your om.next

roklenarcic17:07:13

that helped with the warning

roklenarcic17:07:42

how do you run your project

Lone Ranger17:07:23

anybody here use a server (i.e. ring) and a client side react app in conjunction with figwheel? When I run figwheel and my ring server they fight with eachother like my parents when I was 11

wilkerlucio17:07:39

@goomba I usually run 2 separated REPLS when doing that, so then can live side by side without talking to each other like a lot of parents.

Lone Ranger17:07:03

maybe I'm just being a dummy but my issue is I need to fetch content from my ring server and when I launch on fw the client app is put on the localhost:3449 and my ring server is living somewhere else

wilkerlucio17:07:05

you have some options

wilkerlucio17:07:32

1. you can just ignore the figwheel server in terms of content deploy, implement static page serving on your ring side, so everyone being at same host/port will just work

wilkerlucio17:07:57

2. enable CORS on your server-side endpoint, so it will accept requests from anyone (or whatever you setup the CORS to accept)

wilkerlucio17:07:45

* CORS is just returning a header from the page being served: Access-Control-Allow-Origin: *, modern browsers will recognize it

Lone Ranger17:07:24

okay awesome... glad at least to hear it's not just me dealing with parental figwheel issues with this 🙂

roklenarcic17:07:02

@madvas The reason reloading doesn't work is Compassus

roklenarcic17:07:43

I guess I'll roll my own routing

anmonteiro17:07:04

@roklenarcic You may have the same problem rolling your own

anmonteiro17:07:33

I haven’t followed the discussion but if you wanna force a toplevel reload you can probably pass a gensymed react key to your top-level element every time

roklenarcic17:07:11

It's weird how Compassus doens't affect om/dom reloading

roklenarcic17:07:18

but material-ui is affected

anmonteiro17:07:32

I’d love to get to the bottom of that issue

anmonteiro17:07:43

can you open an issue in the Compassus repo with a minimal repro?

roklenarcic17:07:59

I'll try tomorrow

roklenarcic17:07:16

my toplevel are routes of course

roklenarcic17:07:30

is there any way to have something else toplevel than routes

roklenarcic17:07:30

I have a header that is independent of routes and now I have it duplicated across all routes

anmonteiro18:07:24

@roklenarcic this is outdated but I think we managed to do reloading in this template https://github.com/compassus/oriens

roklenarcic18:07:46

Reloading worked for me too

roklenarcic18:07:58

when I had something like (dom/button nil "ABC")

roklenarcic18:07:30

now I wrap it in ui/mui-theme-provider and it stops working

roklenarcic18:07:44

and if I disable compassus it starts working again

roklenarcic18:07:05

Here;s a quick pastebin writeup

roklenarcic19:07:20

what's the best way to access javascript object properties?

bostonaholic19:07:31

goog.object/get

nwjsmith19:07:37

(goog.object/get #js {:foo 1} "foo")

nwjsmith19:07:55

(hi matthew) 😉

bostonaholic19:07:30

poppin’ champaign today, I’m sure (offtopic)

roklenarcic19:07:00

how is that better than aget?

mfikes19:07:11

Well, aget is for arrays

roklenarcic19:07:27

you sure? It worked for an object for me

mfikes19:07:01

Yes, all the a- functions are for arrays. aget happens to work, but is is only an accident of the implementation. It is not really guaranteed to work.

mfikes19:07:28

By a-, I mean, amap, aclone, areduce, etc.

mfikes19:07:01

If you try aget on an object in Clojure, you’ll definitely see it not work there FWIW

mfikes19:07:08

Otherwise, goog.object/get is 👍

pcj19:07:10

well I've been using that all wrong 😞

mfikes19:07:36

@pcj You are not the only one. The core libraries have it wrong as well.

mfikes19:07:05

I think one of the best analogies is (+ "foo" "bar") concatenates strings, but + is not for strings

dnolen19:07:59

@pcj well that’s not an official cheatsheet, we’ve never recommending doing that

pcj19:07:52

Oh okay. Thanks for clearing that up!

dnolen19:07:08

the problem is we didn’t disallow it and there’s a lot of code in the wild that continues to do so

dnolen19:07:23

to be fair, ClojureScript itself also did this and we’re in the middle of cleaning it up

dnolen19:07:35

and providing a flag to detect issues at compile & runtime

mobileink19:07:00

stupid question: why not get? i'm (slowly) working on Compleat Interop docs for cljs. should aget be deprecated for property access, in favor of goog.object/get?

pcj19:07:30

Looking at the github issues for that cheatsheet it looks like the owner is aware, thanks to @mfikes.

rgdelato19:07:13

I guess in response to mobileink's question, I would expect something like goog.object/get to be in the standard lib as oget since we already have aget

dnolen19:07:23

@mobileink it’s simple though not obvious

dnolen19:07:39

you can’t monkey patch JavaScript objects to make them ILookup

dnolen19:07:02

if you make get work for JS objects you damage ILookup performance cause you have to check for this special case

dnolen19:07:23

adding oget isn’t a good idea since what’s the point? goog.object gives you that a bunch of other stuff

dnolen19:07:41

none of these decisions are going to change, so further discussion is unnecessary

rgdelato19:07:14

then I guess it's more a documentation issue than anything

mobileink19:07:53

thanks. not interested in changing things, just really explicit and complete doco for us simple minded folks.

mfikes19:07:15

@rgdelato FWIW, the docstring for aget in ClojureScript master has been updated to read “Returns the value at the index/indices. Works on JavaScript arrays.”

mfikes19:07:01

(Analogous to Clojure’s docstring and Java arrays.)

rgdelato19:07:20

@mfikes oh yeah, I've never used it for objects. the docstring is good. it's just surprising to me that there isn't an equiv oget, so it takes a bit of research to figure out what the obj equivalent is

dnolen19:07:14

@rgdelato @mobileink is working on a new interop docs thing that we need to get around to reviewing, it will get covered soon-ish

dnolen19:07:26

to be fair why get doesn’t work for JS Object is simply never going to be obvious to newcomers

dnolen19:07:30

its just boils down to performance

dnolen19:07:22

even if we tell newcomers to use goog.object/get, I don’t see how they’ll get it

dnolen19:07:32

sometimes you just can’t make everyone happy and this is one of those cases

dnolen19:07:12

in the whatever docs we write, we should probably mention the performance decision as a footnote

mfikes19:07:26

I suppose, even if you could write (get obj "foo") then this would become non-portable, specific to ClojureScript. OTOH (get (to-array [1 2 3]) 1) is fine in both dialects.

mobileink19:07:03

@dnolen re: performance. i'll have to think on it more, but i'm inclined to think it deserves a separate article in Guide. I see lots of performance related stuff here, Not essential for Ref docs, but good for Guide docs, i think.

dnolen19:07:54

I don’t think talking about performance is really that important to be honest not on the official site

dnolen19:07:00

if you want it you can get it

dnolen19:07:06

most people don’t care

dnolen19:07:25

since we made the right decisions up front for many kinds of programs

mobileink19:07:49

i never worry about it, so i'm good with that. i don't have any insanely great ideas for performance docs anyway, atm.

dnolen19:07:03

it’s better left unsaid 🙂

dnolen19:07:25

if you want to know the deep dark secrets you can always spend a couple of days reading the data structure implementations in the standard lib

mobileink19:07:27

good topic for specialized 3rd party docs. "High-Performance Clojurescript". Anybody? 😉

mobileink19:07:55

@dnolen re: interops docs, i've got more draft text, but i'm wondering if piling on PRs is efficient for sth still so up in the air. wouldn't it be better to do some blogs to start and turn them into a PR? thinking it would be easier for you than dealing with prs, dunno. your call.

dnolen20:07:33

@mobileink if you want to post your own thing that’s fine

dnolen20:07:45

I haven’t had time to look at those PRs because there’s a bunch of pressing release stuff in flight

rgdelato20:07:06

new release stuff is exciting though, code splitting <3

mobileink20:07:15

great, thanks. here's a more general question for the community. i have some ideas about docs. they may or may not be acceptable to the maintainers. in development, i have some metadocs, involving things like a list of stuff to cover, a general strategy/plan, etc., which would not be included in the final result. also various drafts which may change drastically. my question: what's the best web service for this kind of thing? assuming it would become a community effort. just using github or a blog seems inefficient to me. i guess i'm asking about a good collaborative doco dev service.

mobileink20:07:39

thanks! not so interested in word processing stuff, but etherpad looks interesting.

rgdelato20:07:38

seems to me like collaborating with an existing site like clojuredocs or something would be a good idea, since they already have the SEO

dnolen20:07:31

I’ll reiterate @rgdelato’s point - going off an doing a new thing is fine - but probably won’t have much impact

dnolen20:07:56

submitting something to the official site will have a lot of impact - you might not be able to write it exactly how you want - but that’s just a tradeoff

tech_hutch20:07:42

But I specified "selfbot-cljs.core" as my :main namespace, unless it's talking about something else :thinking_face:

tech_hutch20:07:58

Oh, maybe I should have asked in #leiningen

wilkerlucio21:07:05

is there a compiler option that allows me to run advanced compilation but without mangling the variable names? I want to make a compilation of some Node.js code in advanced more for the performance optimizations, but I don't mind at all about reducing variable names (since in a Node.js the size doesn't matter so much)

lwhorton21:07:39

@wilkerlucio there’s a debug flag that doesnt fully mangle names: psuedo-names https://github.com/clojure/clojurescript/wiki/Compiler-Options#pseudo-names

wilkerlucio21:07:23

@lwhorton thanks, I'll try that 🙂

rgdelato21:07:29

is there a "get-in"-style function for JS objects, or would you just some-> a bunch of goog.object/get calls to safely get a deep property?

dnolen22:07:07

it’s probably worth bookmarking this page 🙂

rgdelato22:07:59

awesome, thank you. I was on that page, but for some reason, I didn't see it (Note: goog.object/getValueByKeys seems to throw on a nil object while goog.object/get returns nil)