Fork me on GitHub
#clojurescript
<
2016-05-19
>
nathansmutz02:05:23

My Clojurescript project root folders seem to fill up with files with names like "f8bfd138da7f43d585080167a45259c083e99eb4-init.clj". What's the popular remedy for that? Does everybody just clean up manually before committing?

sbmitchell02:05:45

Has anyone used prismatic schema definitions to generate an application debugger for a global app state? Basically, my app is a hash-map backed by a schema but id like to generate an editable component tree for each section of the schema. Ex. a property in the schema is of type s/Str. I'd like to convert that into an input component so you can edit the state that way as well for debugging. Generating the tree is fine but I cant seem to take a definition in the schema say an s/Str and determine what type it is. It seems like there should be a helper func in prismatic but I just cant seem to find one

sbmitchell02:05:23

I can obviously also just do this in a repl but Id like to do it in the web app itself

sbmitchell03:05:38

Looks like I can just do a simple equality check (= <target-in-schema>) so nvm folks 🙂

danielcompton03:05:44

@nathansmutz: that doesn’t sound normal, can you post your cljsbuild config and that file? I have a feeling that that file is coming from an editor/IDE, not CLJS.

jimmy03:05:47

does anyone experience the problem in figwheel that when I hit browser's refresh, the console just shows this Figwheel: trying to open cljs reload socket utils.cljs:38 Figwheel: socket connection established then nothing shows on browser. somehow it just hangs there. Restart the project with lein figwheel works, but then it takes too much time. [lein-figwheel "0.5.3-1"]

danielcompton05:05:15

@nathansmutz: Can you post 8bfd138da7f43d585080167a45259c083e99eb4-init.clj too?

danielcompton05:05:26

yeah that does look like Figwheel, haven’t seen that before, maybe try in #C1A38UB5X ?

savelichalex05:05:42

Is there any way to use ->> with assoc?

sbmitchell05:05:28

what are you trying to do

sbmitchell05:05:49

why not just use ->?

savelichalex05:05:55

I know that this not right, and that ->> insert db as last argument

savelichalex05:05:34

How -> help me?

sbmitchell05:05:43

because that would thread it as the first arg

savelichalex05:05:15

Ow, I got it, thx!😄

sbmitchell05:05:39

I mean there probably is a way to make it work with ->> using an anon fn or something

sbmitchell05:05:44

to swap the args

savelichalex05:05:22

What is it anon fn?

savelichalex05:05:14

Can you show an example please?

sbmitchell05:05:54

I mean this works but id never use this in code (->> {} (#(assoc % :a :b)))

savelichalex06:05:14

I'm just trying to understand all this things, thx)

sbmitchell06:05:23

if I were to do something like that id probably make a swap fn or something

sbmitchell06:05:00

but id just use -> 😛

savelichalex06:05:49

I have one more question) It’s about anon fn) Why if I use this, for example with swap! like this (swap! atom #({:a 1})) then have error - Invalid arity?

sbmitchell06:05:16

you cannot call a hash-map with that syntax in an anonymous function

sbmitchell06:05:23

youd need to use hash-map

sbmitchell06:05:45

that goes the same for vectors, sets, etc

savelichalex06:05:38

That mean that error for hash-map as fn, not for anon fn?

sbmitchell06:05:56

(swap! atom #(hash-map :a 1))

sbmitchell06:05:21

that would change the value of the atom to be that hashmap

sbmitchell06:05:32

the % in this case would be the previous atom state

savelichalex06:05:00

thx a lot, I got it)

sbmitchell06:05:08

cool have fun!

savelichalex07:05:47

Hey guys, how you work with js promises from cljs?

thachmai07:05:10

from a JS perspective, Promise is just an object with a "then" method

thachmai07:05:34

so you can call (.then js/promise-object) directly

savelichalex07:05:32

But this doesn’t look good for cljs) Is there more idiomatic way for cljs?

thachmai08:05:06

personally I use re-frame, and we use handlers/subscribers instead of promises

thachmai08:05:57

but when you receive promises from js from a library, you need to extract the promise result with .then; then transform it into the re-frame model

thachmai08:05:15

would it cool to see how others do it as well

savelichalex09:05:42

@thachmai: Right now I’m doing such thing with promises and re-frame, but anyway this doesn’t look good to me)

risto11:05:19

@savelichalex: You can also do (js/Promise.then (fn [result] ...)) or convert the promise to a channel and just use core.async, though you could probably skip that step and do a channel for a callback instead

savelichalex11:05:25

@risto: core.async looks better)

plexus11:05:40

what would you call #js? reader tag? reader macro?

grav13:05:23

cljs.reader/read-string and tagged literals? How to?

grav13:05:04

Oh .. (r/register-tag-parser! 'db/id second)

symbit14:05:22

Any tips on writting the extern for this JS anonymous function?

fasiha15:05:02

Am I a bad web developer for never testing my sites with Opera?

bostonaholic15:05:01

what percentage of your users use Opera?

roberto15:05:02

not unless you don’t test it with lynx and links either

blissdev15:05:59

opera is also chrome now (engine-wise)

risto17:05:42

@blissdev: Doesn't cover the CSS though

risto17:05:14

@fasiha: I think Vivaldi is gaining some traction, it's from some of the people behind Opera.

mfikes18:05:30

Nice. It looks like ClojureScript has crossed 6000 stars

dnolen18:05:20

@bhauman: it would be nice if I could load figwheel-sidecar without the nREPL dependency - is there any reason this is necessary?

dnolen18:05:27

hrm is it possible to run the Figwheel REPL on a port and connect to it?

bhauman19:05:58

@dnolen: nREPL dependency? There isn't one right?

bhauman19:05:22

You could of course make a socket repl.

bhauman19:05:22

Oh shoot there is an nrepl dependency

bhauman19:05:46

I meant to use resolve to get rid of it.

dnolen19:05:42

@bhauman: yeah it’s not a big deal but it would be nice to not need to declare it since I’m not using it

bhauman19:05:18

my mistake by not putting it in the dependencies

bhauman19:05:29

@dnolen: and figwheel can launch a nREPL server if you supply an :nrepl-port in the fighweel-options

dnolen19:05:45

@bhauman: yeah not going to do that 🙂

dnolen19:05:54

however I think I can just embed in clojure.core.server

bhauman19:05:31

@dnolen: you trying out a new setup?

bhauman19:05:58

@dnolen: just curious cause I have been looking at this a bit lately

dnolen19:05:07

@bhauman: yes playing around with something, if it works I will probably write something about it

dnolen19:05:11

been slackin’ on my blog

bhauman19:05:16

@dnolen: for editor tooling and such, it seems like you could provide a special function that dispatches commands

dnolen20:05:14

@bhauman: how I can make the figwheel connection work if I’m running my own webserver thing? Is this documented anywhere?

dnolen20:05:27

I just want refreshing & REPL - I can’t use Figwheel for serving content

bhauman20:05:00

@dnolen: super popular question. It works automatically

dnolen20:05:33

ah just from letting Figwheel handle the build?

bhauman20:05:02

If you have :figwheel true it sets up the connection

bhauman20:05:31

normally it connects a websocket to <ws://localhost:3449/figwheel-ws>

lewix20:05:59

simple debugging (clear descriptive error messages) is underrated in clojure land even though immutability/pure functions/and all the FP goodness make things 'simple' as per Rich Hickey terminology. Errors messages are insane, it adds to the complexity 😕

dnolen20:05:09

@lewix it’s not so much that error messages are not valued - they are - the question is about whether hiding all the information is actually desirable - for newcomers sure - for experienced users not so much

sbmitchell20:05:38

I have no complaints with cljs errors personally. I guess in the first 2 weeks of using cljs I found the errors to be hard to understand but that was more so from a lack of understanding the language

dnolen20:05:00

@lewix also you have a problem with specific error message or case - better to describe it - then we can actually fix something 🙂

sbmitchell20:05:53

The only problems I could probably even callout are react component rendering issues and I'm pretty sure thats just because I'm not using a development version of react 😛

dnolen21:05:29

@bhauman: what’s the difference between top level :figwheel and :figwheel-options ?

bhauman21:05:38

@dnolen: what context are you using it in?

bhauman21:05:49

(start-figwheel!)?

dnolen21:05:55

@bhauman nevermind I looked at the figwheel-sidecar docs

dnolen21:05:03

I see I can set :server-port and :server-ip at the top level

bhauman21:05:41

@dnolen: its funny I'm working on this inconsistency right now

bhauman21:05:57

I'm sick of having two types of configuraiton schema

dnolen21:05:10

yeah it was a bit surprising

bhauman21:05:13

and I'm sure everyone else is two

bhauman21:05:33

one was internal and leaked

dnolen21:05:41

today has been a happy day so far I must say

dnolen21:05:55

component + figwheel-sidecar + clojure.core.server

dnolen21:05:03

it’s nice when stuff composes simply

dnolen23:05:03

@bhauman got everything I needed working, Figwheel is nicely configurable 🙂

bhauman23:05:50

@dnolen: awesome, good to hear 🙂

bhauman23:05:52

did you connect it to emacs/cursive as well?

cfleming23:05:47

@dnolen: Agreed, I went through it with @bhauman the other day planning to integrate into Cursive - it’s very nice.

dnolen23:05:15

@bhauman: cursive doesn't support socket REPL yet, so Emacs inferior lisp for now