This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-07
Channels
- # aleph (3)
- # aws (7)
- # beginners (117)
- # boot (119)
- # cider (2)
- # cljs-dev (3)
- # clojure (193)
- # clojure-austin (1)
- # clojure-dusseldorf (4)
- # clojure-finland (5)
- # clojure-france (5)
- # clojure-italy (7)
- # clojure-portugal (1)
- # clojure-russia (204)
- # clojure-serbia (5)
- # clojure-spec (31)
- # clojure-uk (64)
- # clojurescript (288)
- # community-development (9)
- # core-async (54)
- # cursive (8)
- # datascript (18)
- # datomic (26)
- # dirac (8)
- # emacs (26)
- # figwheel (1)
- # hoplon (16)
- # jobs (2)
- # jobs-discuss (4)
- # juxt (1)
- # lein-figwheel (4)
- # leiningen (14)
- # london-clojurians (2)
- # lumo (17)
- # off-topic (44)
- # om (63)
- # om-next (2)
- # onyx (26)
- # perun (14)
- # planck (5)
- # portland-or (34)
- # proton (2)
- # protorepl (8)
- # quil (1)
- # re-frame (6)
- # reagent (16)
- # remote-jobs (4)
- # ring (7)
- # ring-swagger (10)
- # rum (1)
- # untangled (2)
BTW @hlolli thanks for https://github.com/hlolli/om-next-template very helpful
if you see some bugs or old versions lurking around, dont hesitate to let me know in pm. I believe I was having some problems with the scss last time, I've been switching entierly to node-sass for sass compilation.
I have a question about an example in the quick start. In the "Naive Design" code in the "Adding State" section, it seems that :count from @app-state is finding its way into Counter's props. How does that work? Does the reconciler just pass @app-state as the props because we aren't using a parser?
#newbie question
I can’t normalize my init-data
and I don’t understand why
There are persons and 2 lists in a dashboard item
(def init-data
{:list/one [{:id 1 :name "John" :points 0}
{:id 2 :name "Mary" :points 0}
{:id 3 :name "Bob" :points 0}]
:list/two [{:id 2 :name "Mary" :points 0 :age 27}
{:id 4 :name "Gwen" :points 0}
{:id 5 :name "Jeff" :points 0}]
:dashboard/items [[:list/by-id :list/one]
[:list/by-id :list/two]]})
(defui Person
static om/Ident
(ident [this {:keys [id]}] "Return the ident for this component"
[:person/by-id id])
static om/IQuery
(query [this]
[:name :points :age]))
(defui ListPerson
static om/Ident
(ident [this {:keys [id]}]
[:list/by-id id])
static om/IQuery
(query [this]
`{:list/by-id ~(om/get-query Person)}))
(defui RootView
static om/IQuery
(query [this]
(let [subquery (om/get-query ListPerson)]
`[{:dashboard/items ~subquery}])))
when I run
(om/tree->db RootView init-data)
I got
{:list/one [{:id 1, :name "John", :points 0} {:id 2, :name "Mary", :points 0} {:id 3, :name "Bob", :points 0}],
:list/two [{:id 2, :name "Mary", :points 0, :age 27} {:id 4, :name "Gwen", :points 0} {:id 5, :name "Jeff", :points 0}],
:dashboard/items [[:list/by-id nil] [:list/by-id nil]]}
might be too large, sorry for that
@astrashe Yep https://github.com/omcljs/om/blob/master/src/main/om/next.cljc#L2372
Technically, not because there is no parser, but because there is no query.
@danielstockton Thanks!
@baptiste-from-paris: you probably forgot to place your list query inside a vector
thx @anmonteiro , does not work for me but I keep trying 🙂
@baptiste-from-paris I would also look at the fact that your ListPerson query also makes a join around :list/by-id
, which is probably not what you want to do.
@baptiste-from-paris further, you’re trying to define your ListPerson ident by looking at an id. But your lists don’t have id keys. The individual list items do, but not the lists as a whole.
Try logging the value of the second argument of ident
.
(ident [this list-person]
(println list-person))
thx @levitanong doing it
it gives me =>
[:list/by-id :list/one]
[:list/by-id :list/two]
Since the thing itself is the ident, all you need to do is:
(ident [this list-person-ident]
list-person-ident)
but of course, i’m not sure this will fix the problem.
but it would be useful to correct your thinking that ident is always {:keys [id]}
nope, but you are helping me understand more
I know, ident is about identity/unicity right ?
wait a minute.
I am just learning om.next and I am looking for the correct workflow for building my UI
i think the problem is you’re trying to normalize it already
how that ?
(def init-data
{:dashboard/items
[{:list-id :list/one
:list-values [{:id 1 :name "John" :points 0}
{:id 2 :name "Mary" :points 0}
{:id 3 :name "Bob" :points 0}]
{:list-id :list/two
:list-values [{:id 2 :name "Mary" :points 0 :age 27}
{:id 4 :name "Gwen" :points 0}
{:id 5 :name "Jeff" :points 0}]]})
ugh, indentation in slack is hard
(def init-data
{:dashboard/items
[{:list-id :list/one
:list-values [{:id 1 :name "John" :points 0}
{:id 2 :name "Mary" :points 0}
{:id 3 :name "Bob" :points 0}]
{:list-id :list/two
:list-values [{:id 2 :name "Mary" :points 0 :age 27}
{:id 4 :name "Gwen" :points 0}
{:id 5 :name "Jeff" :points 0}]})
here, your List ident will be
(ident [this {:keys [list-id]}]
[:list/by-id list-id])
your persons weren’t being normalized because your ListPersons were already manually normalized, and om.next couldn’t make the connection
getting closer but not there yet =>
{:dashboard/items [[:list/by-id
{:list-id :list/one,
:list-values [{:id 1, :name "John", :points 0}
{:id 2, :name "Mary", :points 0}
{:id 3, :name "Bob", :points 0}]}]
[:list/by-id
{:list-id :list/two,
:list-values [{:id 2, :name "Mary", :points 0, :age 27}
{:id 4, :name "Gwen", :points 0}
{:id 5, :name "Jeff", :points 0}]}]]}
when I tree->db
@baptiste-from-paris i’d like to continue helping, but it is already time for me to sleep. I’ll get back to you in 8 hours 😉
good luck, man!
ahah, that’s more than enough 😉
thx a lot
happy to help
@baptiste-from-paris: The person query should have an :id
in it. Person's ident is expecting an :id
.
my person’s ident
is never called
don’t understand why
i have some props that contain idents e.g. {:members [[user/by-id 1] [user/by-id 2]]}
. i'm passing each item in members
to a child component that has an om/Ident
and an IQuery
but the ident is not replaced with the props that i'm querying – e.g. [:db/id :user/name]
– the props in the child just show up as [user/by-id 1]
... any idea why?
however: if i remove the om/Ident
on the child component it happily obtains correct props
@devth are you calling db->tree
in the parser to get the actual props?
if the app state is normalized, you need to call db->tree
to get the actual props, and not the references
@baptiste-from-paris: I'm not surprised. Non-normalized data is actually supposed to be normalized in that objects are supposed to refer to one another by ids. What db->tree does is put your data into default database format. So I'm saying even your non-normalized data should be normalized, at least in so far as it uses idents to refer from one object to another. That's the way I've always done it anyway.
I'm a bit rusty and not sure about that key with your data, but whatever the key is it needs to be repeated and have the actual data in it, so :list-values [{:id 1 :name "John" :points 0} {:id 2 :name "Mary" :points 0}{:id 3 :name "Bob" :points 0}]
@baptiste-from-paris: For example in this SO answer http://stackoverflow.com/questions/35554592/normalization-and-idents-in-om-next see what is done with :app/messages
, a key inside :app/session
.
ok, ill take a look after lunch and let you know, thx a lot
For components without queries, is there any reason to use om/computed? You can give them anything you want as long as you dont transact from them, correct?
you can also transact!
from them I believe
@anmonteiro thanks!
the transaction will actually happen from a parent
or to be precise, the nearest parent which has a query