This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-12
Channels
- # admin-announcements (3)
- # beginners (17)
- # boot (52)
- # braveandtrue (95)
- # cider (4)
- # cljs-dev (2)
- # clojars (118)
- # clojure (146)
- # clojure-art (4)
- # clojure-austin (1)
- # clojure-finland (20)
- # clojure-italy (33)
- # clojure-nl (1)
- # clojure-russia (49)
- # clojure-spec (136)
- # clojure-uk (28)
- # clojurescript (134)
- # clojutre (1)
- # conf-proposals (64)
- # cursive (3)
- # datomic (76)
- # hoplon (11)
- # ipfs (7)
- # jobs (1)
- # jobs-rus (1)
- # leiningen (4)
- # luminus (4)
- # mount (9)
- # om (34)
- # onyx (34)
- # proton (1)
- # re-frame (4)
- # reagent (35)
- # ring (2)
- # ring-swagger (6)
- # rum (15)
- # untangled (87)
defui SearchTable [{[:search :tab] [:es-type :es-sort-fields :sort-ascending?]}
{:hits (get-query SearchTableRow)}
:total]
i do load-field-action on :hits in SearchTab, and this causes the props to have not-found
so far I haven't noticed any issues in production with this, and everything still works as expected
but it would be nice if load-field-action excluded [:search :tab] like it would exclude :ui/foobar
so the api-read is going to see a query like [:search [{:hits [:hits :total [:search :tab]]}]]
load-field has a :without
option for this kind of case, but not sure we tested an ident case
i agree the case is contrived a bit, but sticking with my analogy on ui/foobar, if I load-field-action on :hits, and the query was [:search [{:hits [:hits :ui/foobar]}]] that would not be sent to the server
i guess that's my confusion I thought an joining on an ident has no meaning server side
so in this case, when the server returns data for the ident, do you automatically merge it into [:search :tab] ?
merge is recursive on return value, and since you asked for it but didn't return it: not-found
though technically the sweep step should turn not-found into literally nothing...that's a minor bug too
it's weird to see anything at all in the global state at [:search :tab :hits [:search :tab]] for the ident [:search :tab], because if I actually returned a value from the server for [:search :tab] it would not exist in the global state at the path [:search :tab :hits ...] the data would be merged into [:search :tab], and then when om.next computes the props for the query [... [:search :tab]] it would fill it in
https://github.com/untangled-web/untangled-client/issues/29 here's the first bug
fyi i'm starting to write a series of little addons to our untangled project, i'm not sure they're suitable for mass adoption, but they work in all our use cases and simplify the API
(defmacro transact!
([txs]
`(transact! (:reconciler @admin.core/app) ~txs))
([reconciler txs]
(let [txs (->> txs
(mapv (fn [xf]
(if (list? xf)
(let [[mutation-sym & args] xf]
(assert (symbol? mutation-sym))
`(list (quote ~mutation-sym) ~@args))
xf))))]
wrote my own defui macro that returns a factory when you do @MyComponent, and also expects query as 2nd argument
(defmacro defui [name q & forms]
{:pre [(symbol? name)
(or (map? q) (vector? q) (list? q))]}
`(let [factory-fn# (atom nil)]
(om.next/defui ~(with-meta name {:once true})
~'static cljs.core/IDeref
(~'-deref [this#]
@factory-fn#)
~'static om.next/IQuery
(~'query [this#]
~q)
~@forms)
(reset! factory-fn#
(om.next/factory ~name {:keyfn (framework.core/mk-defui-keyfn ~name)}))))
in our mutations you can bind a mutation namespace to an ident, so that the 'ref' is always set to the binding for any mutation that begins with myns/foobar
(m/bind-ns-to-singleton-ref! 'search admin.ui.search.core/SearchTab [:search :tab])
this let's us transact! from anywhere on (search/...) and still have the mutation implementation leverage 'ref'
(m/bind-ns-to-component! 'search-row admin.ui.search.table/SearchTableRow)
in this case when transacting on this, (presumably a child of SearchTableRow such as SearchTableRowColumnXYZ ) any mutation that that has namespace search-row/xxx will find the nearest parent with component type SearchTableRow(defmethod m/mutation 'search-row/activate-listing [env _ params]
{:action (fn []
(m/swap-this! env assoc :status "ACTIVATED"))})
Yeah, I like the swap helpers. Not quite following what the bind things are doing. I'm a little tired today...not thinking very fast 😕