This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-09
Channels
- # announcements (14)
- # architecture (42)
- # babashka (23)
- # beginners (37)
- # biff (8)
- # calva (2)
- # cider (3)
- # clara (42)
- # clerk (14)
- # clojure (55)
- # clojure-brasil (3)
- # clojure-dev (5)
- # clojure-europe (18)
- # clojure-hungary (88)
- # clojure-losangeles (3)
- # clojure-nl (1)
- # clojure-norway (66)
- # clojure-uk (9)
- # clojurescript (16)
- # core-logic (16)
- # datomic (6)
- # fulcro (32)
- # hyperfiddle (25)
- # instaparse (12)
- # joyride (2)
- # lsp (13)
- # malli (15)
- # off-topic (50)
- # polylith (11)
- # portal (3)
- # re-frame (2)
- # reitit (2)
- # sci (8)
- # shadow-cljs (16)
- # tools-deps (13)
- # xtdb (5)
anyone have tips on organizing complex uis so they compose well? also, higher abstractions for building forms with validation? (currently using atoms for individual fields) i suspect HFQL will help with the second one, but we'll have to wait for that i guess
are you struggling to compose UI components? Electric's main primitive is a lambda (e/fn), which should compose out of the box. re forms with validations - we don't have demos to show here yet as most of these were client specific. Using an atom per field works for field-level validation, you could also use an atom per form for form-level validation
yes I'm really enjoying being able to compose UI with functions. I'm trying to figure out routing at the moment which I've heard folks use reitit for. If anyone has a minimal routing example I'd like to see it
Also for managing app data is it best practice to use atoms scattered around? Or a client-side app db? Or is it recommended to use a streaming database and be reactive on the server-side db?
if you search in:#hyperfiddle reitit
there's a setup from @U050CJFRU and @U06B8J0AJ
there is no best practice, all of it works. Depends on your requirements really. Do you need data to stay on the client? Do you need it to survive machine restarts? Should the data be visible across multiple tabs? Multiple devices? Multiple users?
I suspected that might be your answer 😅 guess I'll need to experiment. Thanks for the help!
yeah, electric should work great with rama. Once differential electric lands it will fit like a glove
It would be nice to have editor plugins that highlighted server->client transfers to help prevent accidental secret leaks:
(e/defn Example
[]
(e/server
(let [secret hunter2]
(e/client secret ;; 'secret' would be highlighted
))))
I could even imagine a linter rule that required one to highlight transferred values somehow (e.g. a reader tag, a casing convention, etc.)given enough resources (money, time) I'd build an electric IDE with many more features... Well, pulling my head back from the clouds, maybe one could extend clj-kondo or tree-sitter to get some functionality. I also wrote a https://gitlab.com/xificurC/hf-electric.el/-/blob/master/hf-electric.el?ref_type=heads for emacs to add a colored background to client/server code. To programmatically prevent leaks one can hold secrets in a non-transferable value, something like
(ns secret)
(deftype Secret [v])
(defn seal [v] (Secret. v))
(defn open [s] (.-v ^Secret s))
and use as
(e/server
(let [secret (secret/seal "hunter2")]
(e/client secret))) ; <- one will see a transfer warning and receive nil
yeah and now that I think about it a bit more, it isn't clear statically (without compilation, at least) where transfers happen
our analyzer infers transfer points without compilation. In theory the analyzer could in the future provide the analysis information through some API. Not on the roadmap
if this is important to you, wrap secrets in a deftype and do not install a serializer for the deftype
you can use e/discard
for now, the difference is only interesting outside of electric. At the missionary layer e/discard
is a flow of nil
s whereas e/inhibit
is a flow that only emits a single nil
e/inhibit is not useful in electric v2
or v3 either, it's a temporary utility for a client project that pulls forward some differential stuff into electric v2