sci

borkdude 2023-10-27T10:57:24.832079Z

😎 Psst, wanna try some hoplon? https://babashka.org/sci.configs/?gist=e83da19df3d2739861334171779f79d5

2023-11-05T19:56:35.276179Z

I'm trying some hoplon on the playground and I think the attribute providers are not being loaded, attributes are not reacting as they should. I tried to require them manually and got ERROR: Could not find namespace hoplon.jquery. {:type :sci/error, :line 3, :column 3, :message "Could not find namespace hoplon.jquery.", :sci.impl/callstack #object[cljs.core.Volatile {:val ({:line 3, :column 3, :file nil, :ns #object[iP view.index]})}], :file nil}. I'm not sure about what I need to do to fix this.

borkdude 2023-11-05T19:57:24.797219Z

I guess the hoplon.jquery namespace needs to be loaded, I didn't do that since I didn't know why I should be doing that

borkdude 2023-11-05T19:57:34.769049Z

can you give an example which triggers that error?

2023-11-05T19:58:44.870629Z

That error is shown when I add hoplon.jquery to the requires

borkdude 2023-11-05T19:59:24.590209Z

don't do that. just give me a code example which shows WHY you need hoplon.jquery at all

2023-11-05T19:59:25.665309Z

I tried to add :toggle to an element with a boolean cell to make the element hide/show when the cell value changed.

borkdude 2023-11-05T19:59:52.030049Z

please, a self-contained example ;)

2023-11-05T20:00:50.669529Z

I'm writing a simpler one, just a minute

borkdude 2023-11-05T20:00:56.949199Z

thanks

2023-11-05T20:02:25.317189Z

;; hoplon_demo.cljs
(ns view.index
  (:require
    [hoplon.core  :as h]
    [javelin.core :as j]))

(def fade? (j/cell false))
(defn hello []
  (h/div
    (h/h1 "Hello, Hoplon")
    (h/p :toggle fade? "Toggle")
    (h/button :click #(swap! fade? not) "click me")))

(.replaceChildren (.getElementById js/document "app")
    (hello))

2023-11-05T20:03:01.958959Z

When I click the button, the p element should hide/show.

borkdude 2023-11-05T20:03:37.311659Z

alright. would it be possible to make a hoplon.dom namespace or so which doesn't use jquery? looking at the code, this should be not so much work?

borkdude 2023-11-05T20:04:24.273969Z

or should I load hoplon.goog perhaps?

2023-11-05T20:04:49.646709Z

https://github.com/hoplon/hoplon/blob/master/src/hoplon/jquery.cljs#L96-L98 This is the code for jquery provider that deals with toggle.

borkdude 2023-11-05T20:05:02.929719Z

it would be better if we would have no goog or jquery, the dom APIs are strong enough these days

2023-11-05T20:05:27.683989Z

hoplon.goog would work.

borkdude 2023-11-05T20:06:20.913439Z

ok I added this to the playground, try refreshing in 5 minutes or so

2023-11-05T20:06:22.788709Z

I agree. We have that because 10 years ago that was not the case. But I want to create one version that uses dom APIs directly.

2023-11-05T20:06:55.432069Z

Thank you!

borkdude 2023-11-05T20:07:13.002349Z

no problem

2023-11-05T20:11:24.505179Z

And it works! gratitude

borkdude 2023-11-05T20:13:44.673079Z

woohoo!

2023-11-05T20:21:26.243889Z

Do I have to do something special to use macros? Both j/defc and h/defelem are failing with Evaluation failed: Could not resolve symbol

borkdude 2023-11-05T20:22:03.891129Z

Those need to be added to the configuration then. I just made work what was mentioned in the README.md of hoplon 🤷 Feel free to make PRs

2023-11-05T20:23:36.937699Z

Ok, thank you. Will do.

borkdude 2023-11-05T20:24:04.474869Z

Run the playground in development mode so you can test

borkdude 2023-11-05T20:24:15.748319Z

if you have any questions let me know