Fork me on GitHub
Fit Opene12:03:30

hello, I just started learning Clojure and I really appreciate this Electric library. However, I don't know how to use it in an Expo + React Native project. I tried modifying the project, but I've been struggling for a day with configuring deps.edn and shadow-cljs.edn, and I can't seem to make it work. Could you give me some advice on this? Thank you.

๐Ÿ™‚ 2
Dustin Getz12:03:10

We have not yet tried React Native, it will likely not work yet with Electric

Dustin Getz12:03:37

I have no reason to believe it won't work, but we know nothing about React Native as a platform, so I'd assume some minor work is required

Fit Opene12:03:37

Thank you for your reply, I will keep trying and hopefully make some progress soon.


would like to set pending state on an atom for a loading state but strangely pending is caught twice

(defmacro set-pending [atm & body]
  `(try (let [ret# (do ~@body)]
          (and (do ret# true)
               (do (println :done) true)
               (reset! ~atm false)

        (catch Pending e#
          (println :pending)
          (reset! ~atm true)
          (throw e#))))


is this on master? There were a couple of fixes around try/catch lately


yup Iโ€™m on master


it's also possible body is throwing Pending twice. Can you provide a repro?


even if it does that should be okay, is there an ultimate Success / return state?


I mean if the body goes e.g. Pending, v, Pending, v then seeing 2 Pendings is fine, right?


this prints a single pending (p/run (set-pending (atom 1) (p/offload #(do 2))))


this sets pending to true but not back to false


I see. That's because in electric almost everything is running concurrently. (try a b c) will run all of them at the same time. So (reset! !p false) will finish before hitting the catch handler


You can do (catch Pending _ (reset! !p true) (e/on-unmount #(reset! !p false)))


to elaborate a bit, the electric code

(do (throw (ex-info "boom" {}))
    (println "hi"))
will both throw and print, because all of dos children are running concurrently


okay great thanks that worked


(defmacro set-pending [atm & body]
  `(try (do
          (e/on-unmount #(reset! ~atm false))
        (catch Pending e#
          (reset! ~atm true)
          (throw e#))))


I'd put the unmount call in the catch block. In your use case ( (dom/on "click" (e/fn [_] <here>)) ) it makes no difference though

๐Ÿ‘ 2

getting a lot of these after reloads, never before

๐Ÿ‘€ 2
โœ… 2

anyone else have that issue?

Dustin Getz20:03:00

i think we are seeing it too

Dustin Getz20:03:08

what commit are you on?




have been seeing it for a while though

Dustin Getz20:03:36

are you doing css work lately?


yes though itโ€™s been intermeshed w everything else

Dustin Getz20:03:37

We're bisecting, the key piece of the repro is to touch a css file and ALSO load it like this: (dom/link (dom/props {:rel :stylesheet, :href "/todomvc.css"}))

Dustin Getz20:03:51

Seems we can repro all the way back to last summer

Dustin Getz20:03:59

Are you also loading css like that?


is there a different / better way to load a css file for electric? That form matches


this is buggy, we're searching why. Seems to be a months old regression

Dustin Getz21:03:08

Yeah you can probably work around this by loading css through index.html

Dustin Getz21:03:35

Peter bisected this back to August 2022, this is the first time we noticed


@U050CJFRU this might be related to a fix we just landed, can you try updating to latest master and see if the problem still persists?


@U09FL65DK it seems to be gone! will report back should I see it again. thank you!

๐Ÿ‘ 4

@U09FL65DK on master still seeing this occasionally


Sorry to hear that. We haven't seen this after the latest fixes, so if you find a good repro let us please know