This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-09
Channels
- # admin-announcements (1)
- # boot (225)
- # braid-chat (1)
- # cider (25)
- # cljs-dev (35)
- # cljsrn (1)
- # clojars (6)
- # clojure (81)
- # clojure-berlin (1)
- # clojure-dev (21)
- # clojure-france (2)
- # clojure-japan (6)
- # clojure-poland (1)
- # clojure-russia (10)
- # clojure-uk (3)
- # clojurescript (121)
- # code-reviews (1)
- # core-async (4)
- # core-logic (2)
- # cursive (15)
- # datomic (8)
- # hoplon (4)
- # jaunt (112)
- # jobs-discuss (35)
- # om (41)
- # parinfer (8)
- # re-frame (3)
- # reagent (4)
- # ring (2)
- # untangled (38)
I read through tutorial, and now I try to play with it, but I'm stuck with working query stuff
anyway, I just initialized untangled client app via simple:
(defonce app (atom (uc/new-untangled-client
:initial-state {:my-value "My value"
:your-value "Your value"}
)))
and when I use simple Root component, such as:
(defui Root
Object
(render [this]
(dom/div #js {}
(str "This are props for this component: " (om/props this)))))
everything displays well (whole state map is displayed in div)but when I add query fragment in this Root component:
static om/IQuery
(query [this] `[:my-value])
then error is raised in Chrome console:
A sanity hint for incoming uncaught error:
return or__26661__auto__;
} else {
return dkey;
}
})();
var by_ident_QMARK_ = om.next.ident_QMARK_ <<< ☢ NULL ☢ <<< .call(null,key);
om_plumbing.cljs:28 Uncaught TypeError: Cannot read property 'call' of undefined
@vmarcinko: upgrade issue
if you are using om 32, you might be using a version of untangled that doesnt work with it so unless theres a newer version of untangled out than what you have, you might need to wait till @tony.kay pushes the fix to clojars
@tony.kay: @adambros Thanx guys. Yes, I updated versions of figwheel-sidecar, om and CLJS to newest version, but I thought I won't have any problems with that because I tried that ugprade with whole untangled-todomvc app, and it worked, thus my reasoning
actually, wrong info from me, i ugpraded CLJS and fighweel, but not om next in todomvc, thus it worked there 😞
especially because I am total cljs/om newb, so dunno how to decypher these error messages
And another noob question, because I'm totally baffled...Anyway, my app state is following, and I got it dumped by conveniente (log-app-state) function :
{:app-name "My First Untangled App",
:people
[{:name "Igor", :address {:city "Osijek", :postcode 31000}}
{:name "Ante", :address {:city "Zagreb", :postcode 1000}}
{:name "Mate", :address {:city "Pozega", :postcode 34000}}]}
And I assumed that by using the query:
[:app-name {:people [:name]}]
I would get following:
{:app-name "My First Untangled App",
:people
[{:name "Igor"}
{:name "Ante"}
{:name "Mate"}]}
but for some reason my component gets this props value:
{:app-name "My First Untangled App", :people [{} {} {}]}
Usually you do the queries against a db that is in 'default db format' so you can get db->tree
to help. Your app state does not appear to be in in 'default db format'.
@vmarcinko: to add to cjmurphy, untangled assumes that your data is in the database format described in the tutorial -- a normalized collection of data and links to that data. If your state is not in that format, we will process it as if it were. That is why you are seeing that value in props -- we are trying to denormalize your database data into a tree, when your data is already in tree format. Lots more information on the normalization process in the untangled and om tutorials, if you're looking for a deeper explanation
@ethangracer: @cjmurphy Thanx again, although in general I udnerstand the idea of normalization, but I thought untangled client would do that for me, when I provide it a initial state map in tree form via (uc/new-untangled-client :initial-state ...) because docs says that Untangled will auto-normalize passed map
so the map I display at the beginning of my previous post is the one I provided as :initial-state option to untangled client constructor
Look at (pprint @my-reconciler) to see if it is normalized (default db format - same thing).
@cjmurphy: Ah, I already manually built normalized version fo this map, passed it to :intiial-state, and noticed it works now, so I guess it does not auto-normalize this map
I'm not even sure how can auto-normalization be perfomed when OM doesn't know what object property has been taken to sserve as identifier - Does it get this information from :keyfn that is set up during factory function creation for that React component or something else?
There's tonnes of examples. I always recommend the Kanban demo - you can see things like {:id 20}
being transformed into idents.
I like Kanban b/c reading it is a top-down way of learning, where as the tutorials are mostly bottom up.
Yeah but it will help with this normalization understanding just to look at it and maybe (pprint @its-reconciler) from the browser dev console.