Fork me on GitHub
#hyperfiddle
<
2023-02-22
>
Tim Brown09:02:21

@dustingetz Electric is awesome from what I've seen! Good job. I have a problem with the ReagentInterop demo: from http://localhost:8080/(user.demo-reagent-interop!ReagentInterop) I get the following 😞 I've done an npm install, along with an upgrade of node to the shiniest (v19.7.0) version... any ideas?

👀 2
Dustin Getz11:02:52

you have to uncomment it in i think user-main.cljc, it’s disabled to make the npm install optional

Dustin Getz11:02:07

we’re working on making the demos easier to run and find

Dustin Getz11:02:17

for now just uncomment the line locally

tatut14:02:06

Pending looks cool, so I can use that to catch a situation where results are not available yet

👍 2
tatut14:02:52

what if I want to keep the previous DOM and show something in addition when Pending, I probably need a client side atom for the results?

tatut14:02:40

like a content that is updating, you don’t want to replace the old content with a loading indicator

JAtkins16:02:30

my initial thought would be maybe priority stream pulls from missionary land..? But I'm not sure how to do that yet, and there's probably a better method

Dustin Getz16:02:35

exceptions leave the try-body in place and running (so the dom stays, the catch-body is meant to add a loading on top of what is already there)

Dustin Getz16:02:58

this is because when the exception "goes away" you need to resume where you were

tatut05:02:29

hmm, maybe the structure of my code is just wrong

👀 2
Dustin Getz11:02:06

send me a gist of what you have and a comment of what you want to happen

tatut14:02:01

I’ll try, I’m not sure what I “want” to happen, as I’m more trying to understand how to use

👀 2
tatut14:02:00

this is one thing I tried, having a catch block in the UI https://github.com/tatut/electric-examples/blob/55e7537544aefeed268354a97d5fa8d5fc9051e6/src/app/ankka.cljc#L99 this looks like it the “loading” block was always showing

👀 2
Dustin Getz14:02:42

Are you running master? I think we might have a regression that matches this report

tatut14:02:57

I updated yesterday, I’ll try with latest

Dustin Getz14:02:16

are you blocked on this?

tatut14:02:49

just doing some examples as I’m going to show some electric to other clojure programmers at work tomorrow

Dustin Getz14:02:10

";; This is showing always after initial showing," i think you are doing it right, this is a bug We refactored how exceptions work this week

Dustin Getz14:02:23

I think if you revert to the published version (v2-alpha-68) it will work properly

tatut14:02:41

I’ll try reverting

tatut14:02:40

even after reverting it seems that it doesn’t work properly, not it isn’t showing all the time… but the pending element only very briefly flashes in existence and is removed

👀 2
tatut14:02:04

even when I added a 2 second thread sleep in my jdbc query function to really see it

tatut14:02:27

if I put a println in the catch block, it is printed twice, once at the start and again at the end of the wait when the element flashes

tatut14:02:16

ah no sorry… the element flashes twice when the waiting starts and after the wait is over

Dustin Getz14:02:52

ok, we will look into it, thanks for the report

Dustin Getz15:02:05

your latest code is on github?

tatut15:02:19

I’ll push this now

JAtkins16:02:06

I don't think this is important to the code, but what's the frequent use of :needle?

Dustin Getz16:02:54

needle in a haystack ... sorry will stop doing that ty for asking

JAtkins16:02:43

np, just curious if it had any interesting meaning

Adrian Smith16:02:54

There's an english? Saying for something that is hard to find "It's like finding a needle in a haystack", in programming it's commonly translated to needle is the thing that you are searching for and haystack is the thing being searched

JAtkins16:02:03

Yup. Sorry yeah it made sense as soon as I saw "needle in a haystack" 🙂

J17:02:50

Hi guys! Does electric support release code with shadow-cljs? The builds of shadow-cljs.edn config:

:builds {:app {:target :browser
                :output-dir "resources/public/js"
                :asset-path "/js"
                :modules {:main {:init-fn }}
                ;; For dev
                :dev {:devtools {:watch-dir "resources/public" ; live reload CSS
                                 :hud #{:errors :progress}
                                 :ignore-warnings true}}
                ;; For prod
                :release {:compiler-options {:optimizations :simple}}}}
But when I pack the uberjar, the server starts but the js log this error in the console. I miss something?

👀 2
Dustin Getz18:02:49

we do support advanced optimizations, let me get back to you

nakkaya18:02:00

I was playing with the same idea, hit the same error. removing optimizations fixed the error. However now when I run the uberjar I get unable to resolve symbol error related to my backend functions. Am I skipping something?

Dustin Getz18:02:16

maybe we broke it, builds are getting reworked wip rn

nakkaya20:02:15

@dustingetz Do you happen to know any repo that shows how to deploy an electric app with or without a jar? Just to cross check what I have.

Geoffrey Gaillard09:02:06

:optimization :simple has been fixed. :optimization :advanced has a regression. We will address it. > when I run the uberjar I get unable to resolve symbol error related to my backend functions > We are addressing this too. We’ll get back to you with an example of how to deploy an electric app with a jar.

👍 6
J12:02:23

Thanks @U2DART3HA it works and I have a valid uberjar too!

👀 2
nakkaya12:02:56

@UHZPYLPU1 Any chance you can share the repo? I am still struggling with building the uberjar.

J12:02:42

I have not repo yet @U5H4U2HEH 😅 but I can describe how I manage the uberjar. This is the view of my src folder:

src
├── client
│   └── estimaty
│       ├── app.cljs
│       ├── routes.cljs
│       └── util.cljs
├── logback.xml
├── main
│   └── estimaty
│       ├── core.cljc
│       └── views
│           ├── header.cljc
│           ├── room.cljc
│           ├── rooms.cljc
│           └── signup.cljc
├── server
│   └── estimaty
│       ├── db.clj
│       ├── repository.clj
│       └── server.clj
So src/client , src/server and src/main are source folder (`estimaty` is the main namespace). In my deps.edn , the dev aliase looks like this:
:dev
{:extra-paths ["dev" "src/client" "src/server" "src/main"]
 :extra-deps
 {binaryage/devtools {:mvn/version "1.0.6"}
 thheller/shadow-cljs {:mvn/version "2.20.1"}}
 :jvm-opts
 ["-Xss2m" ; 
  "-Dclojure.tools.logging.factory=clojure.tools.logging.impl/slf4j-factory"
  "-Dlogback.configurationFile=src/logback.xml"
  "-XX:-OmitStackTraceInFastThrow" ;; RCF
  "-XX:+UnlockDiagnosticVMOptions"
  "-XX:+DebugNonSafepoints"]}
Now this is the build.clj to build the uberjar:
(ns build
  (:require [clojure.tools.build.api :as b]))

(def lib 'io/estimaty)
(def version "0.0.0-alpha0")
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def uber-file (format "target/%s-%s-standalone.jar" (name lib) version))

(defn clean [_]
  (b/delete {:path "target"}))

(defn uber [_]
  (clean nil)
  (b/copy-dir {:src-dirs ["src/server" "src/main" "resources"]
               :target-dir class-dir})
  (b/compile-clj {:basis basis
                  :src-dirs ["src/server" "src/main"]
                  :class-dir class-dir})
  (b/uber {:class-dir class-dir
           :uber-file uber-file
           :basis basis
           :main 'estimaty.server}))
The server should know your server function. Maybe there is a better solution ^^.

👀 2
nakkaya13:02:17

@UHZPYLPU1 mine is pretty much same as yours. I do get the uberjar and it loads fine, my problem occurs when I try to execute backend functions with e/server I get symbol can not be resolved error. Did you had to change anything in front end init code? In my case I split user.clj in to two, dev still launches user.clj but jar uses core.clj that has jetty start logic without shadow-clj stuff. Similarly I moved user.cljs to core.cljs and updated shadow edn accordingly.

👀 2
J13:02:19

> I get symbol can not be resolved error This occur on the server, right?

J13:02:39

Have you required your backend function to the entry point of your uberjar?

nakkaya13:02:33

When you say backend function, I have a core/-main that jar executes which starts jetty, or do you mean something else?

J13:02:30

In my example, my -main function is into the server.clj . In this file, I have required the backend namespaces used by all the views (like db.clj, repository.clj)

nakkaya13:02:20

@UHZPYLPU1 lol, looks like I fixed it without realizing I fixed it. I required db ns to handle authentication in my jetty ns. Like you pointed that fixed the issue but at that point last night I already gave up on the jar so never tested again. Thank you.

😁 2