Fork me on GitHub
#clojurescript
<
2018-07-19
>
henrik10:07:50

With regards to VDOM or lack thereof, I’m excited to see what #precept / https://github.com/CoNarrative/precept can cook up.

kennytilton11:07:51

@henrik Thanks, I did not have Precept on my radar.. Looks brilliant. I wonder if they can hide the rules thing. At a not very high scale logic programming can be a bear.

henrik11:07:31

@hiskennyness Yeah, it’s hard to predict the ergonomics of managing a sufficiently large site as rules right now. If the base concept is successful, there will probably be abstractions layered on top of it.

cjmurphy12:07:15

Just been bitten by (clojure.string/blank? :a) yielding false from a cljs REPL and throwing an exception from a Clojure REPL. How do I check to see if something has already been filed? Or is this just difference supposed to live with?

kennytilton12:07:56

The problem I see, @henrik, is that we want to write natural, branching code that happens to work off app state here and there, without thinking about anything other than what we are building. To automatically rewrite that as logic rules almost takes compiler support. I think Prolog could be the poster child for cool things that utterly did not scale beyond Socrates being mortal.

mfikes12:07:59

@cjmurphy (clojure.string/blank? :a) is not a valid program right? (It has undefined behavior.)

cjmurphy12:07:18

That's just what I typed into two REPLs, a Clojure and CLJS one. Not sure what you mean really.

mfikes12:07:14

clojure.string/blank? only accepts CharSequence in Clojure, and strings in ClojureScript. If you pass it anything else, then the behavior is undefined.

mfikes12:07:43

In the future, you may see instead

user=> (clojure.string/blank? :a)
ExceptionInfo Call to #'clojure.string/blank? did not conform to spec:
In: [0] val: :a fails at: [:args :s] predicate: (instance? java.lang.CharSequence %)
on Clojure and something similar in ClojureScript, but related to string?.

cjmurphy12:07:56

Okay I see. Spec will help me/us out here down the track. Happy path only for Clojure(Script) functions.

mfikes12:07:35

(I'm assuming this is the case based on item 4 in (doc clojure.string) in Clojure, and by making a few mild assumptions.)

mfikes12:07:23

Yeah, definitely. "Happy path only" matches my "valid program" language.

adam15:07:51

I updated some dependencies then downgraded. Figwheel was working before that but now I get "WebSocket connection to '<ws://localhost:9091/>' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED goog.net.WebSocket.open @ websocket.js:279" ... "Closed Websocket REPL connection". I even deleted the entire repo and cloned it again from origin and still getting this error! Are the updated files cached outside the project directory?

bhauman15:07:36

@somedude314 try deleting the ~/.cljs/.aot_cache

bhauman15:07:18

there is a version of CLJS that caches in a strange way that can break things

bhauman15:07:34

but also the browser is a fickle beast

adam15:07:45

@bhauman: Same issue 😞 I actually updated ClojureScript yesterday but reverted the version number today. I am on a Mac.

adam15:07:23

~/.cljs dir is empty

adam15:07:55

I tried rebooting my machine as well and tried multiple browsers

bhauman15:07:37

is the '<ws://localhost:9091/>' url correct?

adam15:07:04

@bhauman I assumed this is something Figwheel uses internally. I am accessing the app from http://localhost:3449

bhauman15:07:22

if you are using a straight lein figwheel setup and haven't set the port then it should be '<ws://localhost:3449/>'

bhauman15:07:11

or you haven't set the websocket-url

adam15:07:03

I will try to see when it's not connecting to that websocket. Thanks for the info @bhauman.

Garrett Hopper20:07:37

Heh, apparently the classpath resource cljs/externs.js file is automatically used by the compiler. I spent quite some time trying to figure out the source of my JSC_DUPLICATE_EXTERN_INPUT error from also adding it to my :externs array.

Bravi22:07:52

is there a different approach to scroll event handler in reagent? all the other events seem to fire, except this one:

(r/create-class
     {:component-will-mount
      (fn []
        (.addEventListener js/window "scroll" #(js/console.log "hello")))
     ...
    })
if I change that to resize, it works

justinlee22:07:58

i don’t see any obvious reason why that isn’t working. reagent shouldn’t have anything to do with it

Bravi22:07:15

hmm interesting

justinlee22:07:36

maybe stick another console.log just before the call to addeventlistener just to double check that the code is running?

Bravi22:07:09

yeah it’s definitely running because if I change that to literally any other word like click, resize, keypress, then it works 😕

justinlee22:07:58

try doing it in the javascript console on the browser

justinlee22:07:23

is there some reason why your code is eating the event?

justinlee22:07:32

i don’t even know if that’s a thing

Bravi22:07:19

yeah it’s not working in console either 😄

Bravi22:07:20

I think something else is blocking it

Bravi22:07:32

because it seems to work in other tabs

Bravi22:07:11

turns out it’s because of css

justinlee22:07:52

i didn’t even know that was possible

Bravi22:07:20

specifically - display: flex on body tag

Bravi22:07:29

yeah I had no idea as well

Bravi22:07:52

phew that’s my 2 hours wasted 😄

Bravi22:07:10

thank you, front end development

Bravi22:07:20

I think it doesn’t register scroll as an actual scroll. this is very odd

Bravi22:07:32

once I remove display: flex, it works

Bravi23:07:33

scratch the above - the actual reason was overflow: hidden on the body tag. the scroll was only visible on a container div

Bravi23:07:56

and looks like by removing display: flex, I was just ruining that overflow: hidden somehow

Bravi23:07:07

and therefore it was starting to work