This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-10
Channels
- # asami (41)
- # babashka (24)
- # beginners (48)
- # calva (41)
- # cider (10)
- # clj-commons (20)
- # clj-kondo (2)
- # cljdoc (8)
- # clojure (131)
- # clojure-australia (4)
- # clojure-europe (17)
- # clojure-hungary (2)
- # clojure-india (2)
- # clojure-nl (3)
- # clojure-uk (1)
- # clojurescript (12)
- # community-development (6)
- # core-logic (4)
- # cursive (11)
- # datomic (22)
- # emacs (25)
- # events (1)
- # exercism (2)
- # fulcro (30)
- # helix (5)
- # honeysql (6)
- # hugsql (3)
- # integrant (12)
- # introduce-yourself (4)
- # lsp (5)
- # malli (5)
- # nextjournal (31)
- # off-topic (4)
- # pedestal (3)
- # portal (51)
- # reitit (33)
- # remote-jobs (1)
- # shadow-cljs (12)
- # sql (10)
- # vim (7)
- # xtdb (37)
For those of you using RAD: I'll be working on it in the coming weeks. There is a rad-1.1 branch on rad, rad-sui, and the rad-demo. I just pushed a form debugger, and the demo at the tip of that branch has a demo of that commented out in the account-forms AccountForm. Basically, it just leverages a combo of the RAD attribute info and the current state to show you a layout of all of the internals of the form's state, along with annotating things with notes/errors so you can see when something is going wrong.
detects things like cardinality errors, nils in idents, and uses the form's validator. ALso shows which fields are "complete" and therefore eligible for checking.
ANN: This new video https://www.youtube.com/watch?v=rzK0_k5lzg4 explains and demonstrates how Fulcro walks the Root query and Client DB in parallel to produce the tree of data that will be passed to the Root component as its props when it is rendered. I hope it will help beginners understand better the query and "connectedness" of the data in the state. Feedback appreciated!
@tony.kay Why does the following client DB lack the table + entry {:c/id {"A.A {:c/id "A.A" :c/n 1}}}
? What am I missing / doing wrong?
(tree->db
(rc/nc [:p/id {:child [:c/id :c/n]}])
{:p/id "A" :child #:c{:id "A.A" :n 1}})
; => {:p/id "A", :child [:c/id "A.A"]}
thanks a lot!
This is a very old function signature from Om Next. I have no idea why it was originally that way. Probably should make a newly named thing that is more plain to use
Been staring at this for a while and canât get it to work. Is something like this not allowed?
(defn expr-ident
[props]
(cond
(contains? props :expr/id) (find props :expr/id)
(contains? props :levels-ref/id) (find props :levels-ref/id)))
(declare ui-expression)
(defsc Expression [this props]
{:ident (fn [] (expr-ident props))
:query (fn [] [:expr/id :levels-ref/id :expr/operator {:expr/operands '...}])})
(def ui-expression (comp/factory Expression {:keyfn (comp second expr-ident)}))
I keep getting Union components must have ident
thrown within the tree->db
functionâŚas far as I can tell Iâve set up Expression
with an :ident
âŚI canât seem to decipher the stacktrace.It would help to see the data tree you are passing to tree->db
.
From the code it seems it fails when normalize*
calls itself here https://github.com/fulcrologic/fulcro/blob/develop/src/main/com/fulcrologic/fulcro/algorithms/normalize.cljc#L47
Here, sel
will be the while query [:expr/id ...]
and if v
is a map, which I assume it is, then you run into https://github.com/fulcrologic/fulcro/blob/develop/src/main/com/fulcrologic/fulcro/algorithms/normalize.cljc#L17 and get the error.
(EQL can contain maps at two places: either joins or union query under a join.)
It would seem to me that you should be getting Expression's ident here. Could it be that props contain somethign that expr-ident
does not handle and thus the cond returns its default nil
? Perhaps add :else (throw ...)
to the cond to make sure that does not happen...
This works fine for me
(tree->db Expression {:expr/id 1 :expr/operator 'inc
:expr/operands [{:expr/id 2 :expr/operator 'dec
:expr/operands [{:levels-ref/id :leaf1}]}]} true)
so I'd really need to see your data.Thanks for the suggestion about expr-ident
. That does indeed seem to be the culprit, but Iâm still not sure why. It seems the props
map being passed to expr-ident
is empty, and thatâs causing the cond to fall through.
The data looks pretty much exactly like what youâve tested above. Hereâs a snippet above.
I donât think initial state would be relevant, because higher up in my component tree is a when
block that prevents this part of the UI from rendering if the data isnât yet available.
Iâm getting this âď¸ the expression doesnât want to fully normalize. It stops after the first entity.
So it seems I only get the error when I normalize from higher up in the component hierarchyâŚusing tree->db
on Expression
seems to work fine. I imagine thereâs something wrong elsewhere that Iâm not seeing. Will keep searching. Thank you for taking a look and trying it out at the REPL!! The expr-ident
hint was very helpful.
You got to me just when I was working with normalize :-)
Basically I have a recursive data structure in which branches have :expr/id
, but leaves have :levels-ref/id
Interestingly, from a normalized starting point, db->tree
actually worksâŚI see the expected tree structure. But trying to round-trip it with tree->db
is complainingâŚ
If you're gettin an union error, then you have a union component with a map as a query...is that true?
You MUST put an ident function on that component that works for any element the union might contain
You're also doing something that seems very strange to me: You're making the table name change (first element of ident) for a single kind of component. That isn't going to work well for a union either...or is at least going to be confusing
Also, find
returns a MapEntry, not a vector...not sure if that matters. I've never tried using a MapEntry
in app state
(cljs used to return vectors instead of MapEntry...but I think it returns MapEntry now...not sure)