Fork me on GitHub
#clojurescript
<
2018-09-12
>
risto00:09:16

is anyone here pretty familiar with core.logic?

risto00:09:59

i'm trying to figure out what's making appendo terminate, from the looks of it, it seems like it should just be infinite like anyo

benzap01:09:13

there's a #core-logic channel that might be more helpful

seancorfield05:09:54

tools.cli has supported ClojureScript for quite a while but it has done so through a separate .cljs codebase. I'm considering moving to .cljc and dropping support for Clojure 1.6 and earlier -- which doesn't seem controversial. I have a question about *assert* tho' -- in the cljs version of the codebase, tools.cli unconditionally performs some debug-level checks on argument spec formats. In the clj version of the codebase, it has (when *assert* ...) around those checks. Having read the differences between cljs and clj, I'm not clear whether that form -- (when *assert* ...) -- is appropriate or not. Input?

seancorfield05:09:08

The other difference in the tools.cli codebase is that clojure.pprint seems to be replaced by goog.string.format in the cljs version -- is that still a fair assumption?

seancorfield05:09:15

Also, since it's been a long time since I last used cljs, what's the current best practice around catch with js/Error vs Throwable? It it still to use reader conditionals or is there something simpler?

macroz09:09:28

hmm tried to use aws-amplify for some logins and ran into this https://dev.clojure.org/jira/browse/CLJS-2738 problem with :npm-deps

macroz09:09:12

looks like I should manually build & include the deps instead because of this feature

risto10:09:58

benzap thanks

mfikes11:09:50

@seancorfield Uaing *assert* should be OK. When set to false in ClojureScript, (when *assert* ...) should expand to nil which should be further completely elided when it is a "statement" (as inside a do). Probably worth checking. There is a cljs.pprint in ClojureScript now. But, it causes some code size issues. So does goog.string.format. But perhaps this is not so much an issue for CLI programs? With respect to catching, typically code does something like #?(:clj Throwable :cljs :default) (At least until https://dev.clojure.org/jira/browse/CLJ-1293 is done and widely deployed.)

abdullahibra11:09:43

is there anybody using "collapse" option of bootstrap ?

abdullahibra11:09:53

within clojurescript

gopunk12:09:13

Hi guys best way to get started with ClojureScript and re-frame fast? 😅

gopunk12:09:13

Thanks 😉

seancorfield16:09:51

@mfikes Much appreciated! I'll look at cljs.pprint to see if I can have a single code base with almost no conditionals 🙂

Ramzi16:09:36

Hi. I'm trying to add a script element in my cljs file. The element is getting in there; I can see it in my inspector, but the script is not running. How can I get the script to run?

Ramzi16:09:42

Here is the code I tried:

Ramzi16:09:44

[:script {:type "text/javascript"} "jQuery(document).ready(function($) {\"alert('hello')\"})"]

Ramzi16:09:50

Here is the output it produced:

Ramzi16:09:09

<script type="text/javascript">jQuery(document).ready(function($) {"alert('hello')"})</script>

Ramzi16:09:30

When I had done just the alert without the surrounding jQuery.ready, the alert never alerted.

john17:09:17

It sounds like you did get the script to run?

Ramzi17:09:36

I got the script tag to appear in the HTML, but not the alert to run.

Ramzi17:09:57

But I'm passed that now. I've got some bizarre error that: Objects are not valid as a React child

Ramzi17:09:34

I have [:div {:id "myGrid" :style {:height "1000px"}}] (let [the-head js/document.head the-script (.createElement js/document "script" ) the-script-value "alert(\"The script was run\");" ] ; if you need to load a js file (set! (.-type the-script) "text/javascript") (set! (.-src the-script) "js/my-grid.js") (set! (.-innerHTML the-script) the-script-value) (.appendChild the-head the-script) ) And my error is: SlickGrid requires a valid container, #myGrid does not exist in the DOM.

john17:09:51

Try this:

(defn load [aname url]
  (let [tag (.createElement js/document "script")]
    (set! (.-id tag) (str aname))
    (set! (.-src tag) url)
    (let [first-script-tag (first (array-seq (.querySelectorAll js/document "script")))]
      (.insertBefore (.-parentNode first-script-tag) tag first-script-tag))))

john17:09:12

well, that's more for pulling in external js. But it works.

heefoo17:09:54

Is there any performance benefit when using transdusers in cljs. I know that in clj one avoids creating intermidiate objects.

john17:09:10

@its.ramzi oh, my bad. It looks like your script is running. But maybe it's running before react has a chance to populate the dom

Ramzi17:09:54

@john It's amazing, calling one line causing my whole page to crash. Without calling your load function, my whole page loads except the table. Calling the load function, only the table loads and none of the page does

john18:09:10

Don't pass in the myGrid as the aname parameter. Just give it a unique name that won't collide with anything else in the dom.

Ramzi18:09:24

I am thinking to make a basic replica of this project to put on github for you to take a look at

john18:09:31

hmm, maybe the function I provided doesn't play nice in a react lifecycle? React is a complex beast.

john18:09:36

You'll probably want to stick your grid lib loading logic in a "componentDidMount" handler somewhere, depending on what react lib your using. It's a non-trivial topic and takes some study to understand.

deliciousowl18:09:43

@clojurians-slack this seemed to actually be the issue with the UIkit components as well last time

deliciousowl18:09:04

resolved via componentDidMount (allegedly idiomatic) or emitting events in react

john18:09:24

mmmm makes sense

Ramzi18:09:57

@john I stripped my program down to the bare bones. I have the app rendering server side. Can you get it rendering client side?

john18:09:56

If you can get a minimal repro up on github, there's a good chance you'll be able to get some feedback on here

Mario C.22:09:49

I upgraded cljs-ajax and it causes my POST requests to break.

Mario C.22:09:27

The way my POST were structured was like

(POST "/exec"
{:format :json
:params {:body (js/JSON.stringify (cljs->js params))}
:error-handler (error)
:handler (fn [r] (put! ch r))
})

Mario C.16:09:54

In case anyone is curious, the solution was {:format :url ...}

Mario C.22:09:39

Does anyone know what I am missing to get it working with version 0.7.3?

Mario C.22:09:50

I tried looking at the docs and they weren't helpful

Mario C.22:09:30

In the previous version we were using, 0.1.3 I noticed that the payload was being sent as Form Data

Mario C.22:09:42

Now it is a Request Payload

john23:09:55

Would folks be interested in a mini static cljs blog that could update itself from a self hosted repl in the browser?

john23:09:15

I've got one half way built, able to push commits. But why aren't self updating static blog sites more popular? Are people worried about security or something?

dustingetz00:09:31

i would love to see what you’ve got

john01:09:01

Cool. I think once I've got it up on github, it should just be forkable, with maybe a little customization.

john01:09:35

Maybe 100% in-browser though