Fork me on GitHub
#hyperfiddle
<
2023-08-31
>
Can08:08:04

Hello everyone, I'm looking for an idiomatic way to add that delay to button. For example, after the user clicks the button it will be disabled for 1 second to prevent multi-clicking etc. How can I show my query's result or alert message on the page with a popup or HTML alert? (I tried js/alert but was not able to progress on it, a popup doesn't appear)

xificurC08:08:11

The ui4 namespace contains a button implementation that disables itself and adds a spinner while the e/fn callback is pending (waiting for server to process your request). This is more resilient and correct than adding arbitrary delays

😮 2
Dustin Getz13:08:28

@U04SVJW7DLZ please paste the code you tried

Can13:09:03

Sorry about my late answer, @U09K620SG I need to re-write that code to send here. (ui/button (e/fn [] (js/alert "hello ") ) (dom/text "alert!") (dom/props {:class "alert" :name "alert-button" :style {:text-align "center"} })) Nothing happened after I clicked the button, I am not sure that I am using it in the correct way but in past Slack massages, I saw some similar usages.

Dustin Getz14:09:47

Looks fine to me, a working button example can be copy pasted from here: https://electric.hyperfiddle.net/user.demo-toggle!Toggle

Dustin Getz14:09:15

try println instead of js/alert

Can15:09:45

println working nicely, I can see printed text on the console. How can I use HTML alerts or JS alerts in Electric. Thanks for separating time 🙂

Dustin Getz15:09:24

are you on latest electric? what version are you using

Can15:09:48

"v2-alpha-284-g0bc5f4bc"

Dustin Getz15:09:57

please upgrade that is very old

Can15:09:40

Oh okey, let me try it. Thank you so much!

Can16:09:51

at java.base/java.lang.Thread.run(Thread.java:833) DEBUG hyperfiddle.electric-jetty-adapter: Client disconnected for an unexpected reason. {:status 1011, :reason Cannot invoke "clojure.lang.IFn.invoke(Object)" because the return value of "clojure.lang.RT.aget(Object[], int)" is null}

Dustin Getz16:09:40

unfortunately you must upgrade

Dustin Getz16:09:31

the changelog documents breaking changes (may not impact you) and you'll need to validate your configuration against the starter app https://github.com/hyperfiddle/electric-starter-app

Can16:09:37

I upgraded but the project doesn't work at the moment.

Dustin Getz16:09:46

You'll need to debug it unfortunately

Dustin Getz16:09:00

Perhaps easier to start with a fresh clone of the starter app and copy your code in

Can16:09:49

oh let me try to debug first 😞 Thank you so much.

Can16:09:30

ERROR hyperfiddle.electric-jetty-adapter: Websocket error

Can16:09:21

this is the error, I leaving this here because maybe someone knows it.

Dustin Getz16:09:36

first thing to check is see if your entrypoint is different from the starter app

Can12:09:18

@U09K620SG hello, https://github.com/hyperfiddle/electric-starter-app/blob/main/deps.edn is that version the latest one? I am going to clone it if yes.

Dustin Getz13:09:13

yes this the latest starter and is the correct thing to clone

Dustin Getz13:09:27

bump electric dep to v2-alpha-428 though