humbleui

Etzwane 2023-07-10T05:27:08.404539Z

Hi Noob question here: I cloned https://github.com/HumbleUI/HumbleUI, and run the example. Open the project in Cursive and connect to socket repl. Problem: I can not get the ui to reload if I change something like a button text, and reevaluate (def ui... in the repl. Also:

Niki 2023-07-10T10:58:02.095489Z

that’s because app is holding onto previous value. UIs are values in Humble UI. When you def new value, it only replaces this var, but doesn’t change any previous references

Niki 2023-07-10T10:58:47.969279Z

For this style to work, you need to re-define top-level app, too

Niki 2023-07-10T10:59:51.828799Z

notice how ui/window accepts either value, atom or var. In last two cases, this allows redefinition. When those are redefined, window will re-render (IIRC, automatically)

Etzwane 2023-07-10T11:39:28.191439Z

I understand, but not quite I think for I can't get it to reload • I turn (def app.. into (defn create-app ... (line93) • I turn line 120 into (reset! state/*app (create-app)) • Now I change something in the loaded example, and re-eval that def • Now I eval (reset! state/*app (create-app))in the repl I expect that should re-create the app, re-include the exaple and swap the atom that went into (ui/window. But, the change is not reloaded

Niki 2023-07-10T11:40:11.392119Z

Did you eval-ed change first?

Niki 2023-07-10T11:40:38.200589Z

In other words, are you sure that value that create-app returns contains new value of your component?

Etzwane 2023-07-10T11:47:39.023429Z

that's the question: I guess it depends on the (ui/dynamic) function. I added a println to create-app, and it prints each time I eval (reset! state/*app (create-app)) so that should be fine

Etzwane 2023-07-10T11:47:59.076309Z

(hope I don't bore you with this nooby stuff.., appreciate the help)

Etzwane 2023-07-10T11:51:47.872789Z

I once saw this video https://www.youtube.com/watch?v=qQvvgzvPgQI&pp=ygURY2xvanVyZSBzbWFsbHRhbGs%3D (clojure in smalltalk style) and I really like the way the smalltalk browser works and make your system discoverable. I would like tot try to build something like this in clojure and why not? in Humbleui

Etzwane 2023-07-10T11:55:41.024169Z

hmm, the ui definition in the example (button in this case) is not re-evaluated it seems.

Etzwane 2023-07-10T12:03:40.690519Z

I made this little test:

(def foo
  ;(ui/dynamic ctx [{:keys [leading]} ctx]
   (ui/label
     (do
       (println "---execution!---")
       (str "bar"))))
So when I eval this with the 'dynamic' wrapper commented, stuff is eval'ed. But with de 'dynamic' wrapper enabled, no evaluation. So that's why my changes won't come through. (the ui val in button namespace is wrapped with dynamic

Niki 2023-07-10T14:13:03.812149Z

It actually should print when you re-eval def foo in both cases

Etzwane 2023-07-11T06:06:16.133769Z

(user/reload) now works well. Thanks!

Etzwane 2023-07-10T05:27:24.425699Z

(examples.state/reload)
Syntax error compiling at (REPL:2:1).
No such var: examples.state/reload

Niki 2023-07-10T10:56:42.092959Z

try (user/reload)

Etzwane 2023-07-10T11:07:11.102949Z

When I do that, amazing things happen. • a fullscreen window opens showing the dependency graph exmaple (in full glory)

Etzwane 2023-07-10T11:07:26.169399Z

The existing app window changes into this:

Etzwane 2023-07-10T11:07:34.994219Z

Niki 2023-07-10T11:35:22.407569Z

Oops :)

Niki 2023-07-10T11:35:57.682909Z

Try removing incremental.clj and incremental_graph.clj

Niki 2023-07-10T11:36:06.835689Z

I guess reload loads them too

Etzwane 2023-07-10T11:44:24.182849Z

yeah, that did some good. The interesting effects are gone. then, for a moment I see the change I made in the example, and then after a second I get this screen, with a counter running up (Not an example I could find)

Niki 2023-07-10T14:13:39.916029Z

This is vdom.clj delete it too

Niki 2023-07-10T14:26:34.963599Z

I’m thinking on how to make them co-exist

Niki 2023-07-10T16:17:41.625409Z

Should be better now, should not require removing any files at least https://github.com/HumbleUI/HumbleUI/commit/c2e4fc996de8c4c48f4ed89f8cfbd0a46edca9f4

Niki 2023-07-10T16:18:02.898359Z

(user/reload) should work out-of-the box

Niki 2023-07-10T16:18:15.371049Z

If you use scripts/repl.py

Etzwane 2023-07-10T17:34:18.522769Z

yes! that works. well done!

👍 1
Etzwane 2023-07-10T05:27:49.018029Z

What am I missing here?