Fork me on GitHub
#hyperfiddle
<
2022-08-24
>
Adrian Smith10:08:48

Noticed I don’t need dom/div and p/defn works for the button, planning to use ngrok to demo to company in 10% time later 🙂

Dustin Getz10:08:53

would you like to contribute it to the demos folder? we are considering making tic tac toe the first tutorial homework

Dustin Getz10:08:09

how did it go? what rough edges did you hit

Adrian Smith13:08:33

Just issues that have already been fixed, when I started the if statement returning x or o wasn’t working correctly (that’s been fixed since), I was able to remove (dom/text) during development and I didn’t understand (defn button returns an object (you helped me fix that) I’m still a bit fuzzy on (fn []) style functions the docs say it isn’t supported yet but not too worried about it right now

Adrian Smith14:08:20

PR here: https://github.com/hyperfiddle/photon/pull/14 going to continue to develop it in another file locally but after adding features I doubt it will be this small again

Adrian Smith14:08:48

I didn’t notice the snake game till now that looks cool

Adrian Smith15:08:46

Found something interesting, I had a bug where I was trying to do (dom/input) on the page that renders ok the page (you see an input box and respects settings like ::dom/placeholder or :placeholder, I was trying to do ::ui/keychord-event based on the chat demo but couldn’t get it working and didn’t notice that I needed (ui/input) because (dom/input appeared to be 90% working

Adrian Smith15:08:29

I think I need to better understand the differences between those namespaces

Dustin Getz15:08:24

ui/input and dom/input have been proposed to be collapsed into just photon-dom

👍 1
Dustin Getz15:08:03

historically, dom/input is a low level dom wrapper and ui/input is higher level abstractions that match Photon idioms

Dustin Getz15:08:22

To clarify the difference between clojure.core/fn and photon/fn,

(ui/button {::ui/click-event (p/fn [_]
                                 (p/server (swap! !x (fn [board pos]
                                                       (update board pos #(case % 0 1, 1 2, 2 0))) offset)))})
this does not work today (using clojure.core/fn inside a p/fn region) but is well defined – we hope to implement this soon. For now you have to factor out the cc/fn today as you did :
(defn update-board! [board pos] (update board pos #(case % 0 1, 1 2, 2 0)))
  (ui/button {::ui/click-event (p/fn [_]
                                 (p/server (swap! !x update-board offset)))})

Dustin Getz15:08:03

p/fn and cc/fn are different types