Fork me on GitHub
#clojurescript
<
2017-12-05
>
sova-soars-the-sora00:12:03

@pmn your lein ring server will start a server on a port different than 3449 usually, have you tried putting clj.main/-main as your :ring-handler ? I think that would do the trick, since figwheel will watch the JS files for changes and also start its own frontend server at 3449... your backend server will start on 8001 it looks like, and that's the one you want to check out and work on once you use backend + figwheel (watch your backend server)

pmn00:12:17

@sova thanks for the tips -- i tried switching over to clj.main/-main as the :ring-handler, but getting the same results; it doesn't seem like it's actually starting it up. it sounds like this should be possible though, so it's probably just a config error on my part somewhere. thanks again!

sova-soars-the-sora00:12:07

:ring-handler hello_world.server/handler: If you want to embed a ring handler into the figwheel http-kit server; this is for simple ring servers, if this doesn't work for you just run your own server. Default: Off

sova-soars-the-sora00:12:25

(quoting the config options of figwheel page)

sova-soars-the-sora00:12:14

projectname.file/function

sova-soars-the-sora00:12:11

agame.main/handler

sova-soars-the-sora00:12:29

@pmn assuming your project is named "agame"

pmn00:12:55

yeah; it seemed like it should start both, i'm guessing i've got something screwy. ah; i wonder if it's jetty vs. http-kit causing the problem

sova-soars-the-sora00:12:57

I dunno. Provided you're handling a hook to your main function it will probably just fire it up. Have you ever heard of Lein Trampoline? Yet another (older) alternative to launching apps

pmn01:12:48

I haven't heard of it; I'll check it out. Thanks for all your help!

potetm00:12:51

@nooga Just some more info: This is part of the UTF-16 spec. UTF-16 characters that fall above U+FFFF are encoded as surrogate pairs. That is, they take up 2 "characters."

potetm00:12:19

Java and JavaScript strings are both encoded as UTF-16 in memory

potetm00:12:08

However, each half of a surrogate pair means nothing in isolation. So it's unprintable.

Ivan Fedorov08:12:25

Good day Channel! Is there anything to read on how npm_modules dir affects cljs compilation? I have an issue with a newbie reagent project, that compiles unexpectedly (for me) and incorrectly if npm_modules is present in the project root (compilation runs from there also).

qqq10:12:48

https://google.github.io/closure-library/api/goog.dom.html <-- anyone have sample code for using setProperties from cljs ?

au-phiware10:12:35

is there a robert.hooke for cljs?

christos14:12:05

Is there a way to get the repl-env in figwheel-sidecar "0.5.4-7" ? I want to connect within vim

sova-soars-the-sora17:12:09

Hi all! Question: what's the idiomatic way to invoke prevent defaults? a submit button redirects on click every time and I'd like to do some form validation before submission/change page

pesterhazy17:12:51

have you tried (defn on-click [e] (.preventDefault e) (do-something-else)) ?

pesterhazy17:12:01

basically just like regular React

pesterhazy17:12:14

N.b. I know nothing about Rum

sova-soars-the-sora18:12:34

There are many gaps in my knowledge of react and js, so thanks for that line of code...

sova-soars-the-sora18:12:24

thank you that worked 😄 @pesterhazy

Melania18:12:56

I am fairly new to clojure. I have been working on building this small app. The app is built with reageant and re-frame (hiccup). One of the component is a dropdown (select/options) that has A-Z. When I press a button called "Play" - I remove the selected letter from the dropdown. (I use javascript library for that) When I press a button called "Start over" I would like to refresh the (select/option back to A-Z). I have tried different ways and nothing works. Any ideas?

dnolen18:12:49

@melania.stewart you seem to be implying that you’re removing the select option child by direct DOM manipulation? This JS library you’re talking about?

sova-soars-the-sora19:12:54

@melania.stewart are you storing the A-Z list in your clojurescript code some place, or does it only exist in the HTML side of the world?

codetaha19:12:18

Everything still works fine and I can run and compile files, this is just a warning but would like to get rid of it. Thank you

codetaha19:12:56

Compilation is done using lein and figwheel

Melania21:12:22

In the click event for the button "Play" I have a let command as follow :

Melania21:12:03

(let [e (js/document.getElementByID "comboID] one of the calls in the body is (.remove e (.-selectedIndex e)) - This will remove the entry. Is this the best way to do this? (I have this question - but I am ok with this, because it does what I want).... But now I want to reset the component with the original list. The component looks as follow (defn combo-div [] [:div {:id "comboID"} [:select {:id "SelectID" [:option {:value "A"} "A"]....up to [:option {:value "Z" "Z"}]) I tried substituting the select component with a ratom and that didn't work. How would you do this? Sorry if I confuse you.

noisesmith22:12:34

@melania.stewart isn’t that mixing paradigms? where reagent is using your data to create a dom, then you mutate the dom itself - I’d expect reagent to just undo the change next time it renders

noisesmith22:12:59

since it is ignoring the dom contents and just translating shadow-dom into a new dom each time

noisesmith22:12:43

usually if we want to remove an element from some :select in reagent, we would programmatically filter the element out before handing it to reagent

Melania22:12:08

How do you do the filtering, could you send me a sniplet? I think knowing the state of the DOM is the key. Are you saying that js routines affect the "real" DOM and not the "shadow" DOM, so when the "shadow" DOM commits into the "real" DOM they overwrite? Are we not suppose to use js methods directly then?

noisesmith22:12:40

you can use js methods directly for things reagent doesn’t control (my app uses this for d3 for example)

Melania22:12:21

I am sorry. what is d3?

noisesmith22:12:24

but if the dom is being created by reagent via your data structure [:select ...] the thing that actually works and doesn’t get undone by reagent is altering the data that you hand to it

noisesmith22:12:46

a js viz lib that doesn’t use react

noisesmith22:12:41

all I meant by that is you can use the js stuff directly, but you probably don’t want to do that for data you are asking reagent to render - the point of using a react wrapper is that react can speed up your render / re-render by managing the dom stuff for you

noisesmith22:12:48

(one point at least)

Melania22:12:32

I understand. I don't think I like to mix javascript with reagant, except when I can't find the right hooks. I am new to this.

Melania22:12:12

So, how would I remove an option using reagent instead of using (.remove e (.-selectedIndex e)?

noisesmith22:12:23

OK - you can use filter inside your reagent data (into [:select] (filter should-include? [[:option …] …]))

Melania22:12:29

If I have a div component as describe above?

noisesmith22:12:49

and should-include? can look at the option items, and could also look at something inside your atom

noisesmith22:12:09

and if you look at an r/atom inside should-include? reagent is smart enough to re-render if the r/atom changes

noisesmith22:12:18

another option is to put the vector with all the :option items in an r/atom, and just put that in the :select

Melania23:12:23

Thank you all!! I am going to try this.

Melania23:12:27

Thank noisesmith!!