clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
2021-06-18T02:17:55.406100Z

I tried that fragment and I think this isn’t what the docs seem to indicate. I think it is supposed to be a Phaser game object, but it is a Window. I tried this and I am still getting some interesting results. I can invoke

(this-as this
  this)
in a cljs REPL. This is what shows it is a window. If I log it I can do some inspection in the Chrome dev tooling. Looks like it has a Phaser object. Based on that, I can do
(this-as this
  (-> this .-Phaser .-Loader))
and that produces a js object that I assume is a loader. I still can’t seem to locate a .image method. Any ideas?

2021-06-18T02:18:29.406300Z

For reference, another simple example I am trying to port is https://gist.github.com/photonstorm/46cb8fb4b19fc7717dcad514cdcec064.

martinklepsch 2021-06-18T10:08:40.408600Z

What are some libraries that you could recommend to build developer tools for SPAs? I’m thinking of stuff like a state inspector and logging events going through the system. Ideally as-a-library that provides some basic building blocks.

p-himik 2021-06-18T10:10:02.408700Z

Out of interest - what do you think is lacking in React Dev Tools, cljs-devtools, dirac, and maybe re-frame-10x and re-frisk if you're using re-frame?

martinklepsch 2021-06-18T10:45:08.408900Z

• cljs-devtools isn’t ideal to navigate large data structures • I’d like to be able to build more custom tools. E.g. for an event logger I’d like to be able to provide a custom component that renders the event and provides collapse/expand type functionality

borkdude 2021-06-18T10:46:19.409100Z

I wouldn't be surprised if the JS world already had stuff for this

p-himik 2021-06-18T10:49:18.409300Z

Oh, regarding large data structures - there's also Reveal, and IIRC it can work with CLJS.

p-himik 2021-06-18T10:50:15.409500Z

But no idea on the libraries. At the very least, you already have cljs-devtools source code that you could take apart and repurpose (just read its license first) or take inspiration from.

borkdude 2021-06-18T10:51:04.409700Z

I think there was also some debugging tool for Clojure/Script that emits events and can visualize it, forgot the name. Was featured on defn podcast

borkdude 2021-06-18T10:52:02.409900Z

https://github.com/jpmonettas/flow-storm

Karol Wójcik 2021-06-18T12:13:38.410500Z

For navigating large data structures shadow-cljs works like a charm

p-himik 2021-06-18T12:21:13.410700Z

I assume you're referring to this: https://clojureverse.org/t/introducing-shadow-cljs-inspect/5012 It's still not really documented, except for that post, so it's rather hard to find.

thheller 2021-06-18T12:45:43.411100Z

there is a second post about it https://clojureverse.org/t/status-update-inspect-cljs-eval/6074 😉

👍 2
thheller 2021-06-18T12:46:37.411500Z

FWIW the underlying shadow.remote architecture the UI uses is meant to tools

thheller 2021-06-18T12:46:51.411700Z

so everything the UI does you also have access too

thheller 2021-06-18T12:47:14.411900Z

but thats even less documented so only the UI currently makes any use of it

thheller 2021-06-18T12:48:06.412100Z

eventually I want that to be extensible but I haven't figured out how to handle custom UI stuff yet given that :advanced makes that rather difficult

olaf 2021-06-18T13:37:39.413200Z

Cljs + Reagent: Uncaught Error: Invalid arity: 0

(defn ui-task
  "Component to wrap a single task"
  [title task]
  [:div {:class "UI-task"}
   [:h2 title]
   [:div {:class "UI-task-container"} [task]]])

(def click-count1 (r/atom 0))

(defn counter []
  [:div
   {:class "UI-task-center"}
   [:label {:class "UI-counter"} @click-count1]
   ])

;; -------------------------
;; Page components

(defn home-page []
  (fn []
    [:span.main
     [:h1 "7GUIs in Clojurescript/Reagent"]
     [:p "This is a live version of 7GUIs with Clojurescript and Reagent."]
     [:ul
      [:li [:a {:href (path-for :items)} "Items of sevenguis"]]
      [:li [:a {:href "/broken/link"} "Broken link"]]]
      [(ui-task "Counter" counter)] ;; <----
     ]))
Last row, is probably causing the error. If commented everything is rendered correctly. How could I debug/find the error?

thheller 2021-06-18T13:39:59.414Z

@eliascotto94 you are not supposed to call component functions yourself. Instead use [ui-task "Counter" counter], so without the (). otherwise what is task? since you are not passing args to that? maybe that expects args? [task]

🙌 1
thheller 2021-06-18T13:41:37.414900Z

oh nvm. it doesn't.

olaf 2021-06-18T13:42:08.415700Z

@thheller Ah.. just that. I don't understand why not the (). I suppose that if I call the function will render my component

:h1 ;; render a <h1>
(ui-task ...) ;; render a ui-task component
No?

Karol Wójcik 2021-06-18T13:44:50.416300Z

Maybe I'm biased, but I find shadow-cljs the best tooling I have ever used!

❤️ 1
Karol Wójcik 2021-06-18T13:45:25.416500Z

A year ago I have introduced shadow-cljs inspect for the events and it really makes the difference

p-himik 2021-06-18T13:48:17.416700Z

No, that's not how Reagent Hiccup works. It requires you to pass the component (the function) itself, not its result. Especially not when wrapped in an extra vector. You can call ui-task, but that will turn it from a proper component into a regular function that just outputs more Hiccup. But it's rare that you'd actually want to do that. More details: https://github.com/reagent-project/reagent/blob/master/doc/UsingSquareBracketsInsteadOfParens.md

thheller 2021-06-18T13:51:23.417200Z

nice to hear that. I always consider the UI unfinished and incomplete but good to see its useful for more people, not just me 😉

olaf 2021-06-18T13:54:24.417400Z

Thanks, interesting!