This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-20
Channels
- # aleph (19)
- # aws-lambda (8)
- # bangalore-clj (1)
- # beginners (13)
- # boot (179)
- # cljs-dev (12)
- # cljsjs (2)
- # cljsrn (6)
- # clojure (174)
- # clojure-italy (14)
- # clojure-nl (2)
- # clojure-russia (172)
- # clojure-spec (29)
- # clojure-uk (22)
- # clojurebridge (10)
- # clojureremote (1)
- # clojurescript (79)
- # cursive (46)
- # data-science (1)
- # datascript (8)
- # datomic (18)
- # defnpodcast (2)
- # emacs (9)
- # events (6)
- # hoplon (11)
- # klipse (13)
- # lein-figwheel (1)
- # leiningen (1)
- # luminus (1)
- # lumo (88)
- # numerical-computing (1)
- # off-topic (24)
- # om (33)
- # onyx (58)
- # protorepl (8)
- # re-frame (10)
- # reagent (26)
- # ring (8)
- # ring-swagger (7)
- # rum (22)
- # spacemacs (25)
- # specter (5)
- # uncomplicate (37)
- # untangled (75)
- # vim (17)
- # yada (3)
@amy_lowe Are you using bidi to match routes? I have something like this:
(defn set-route!
[{:keys [handler route-params]}]
(let [current-route (compassus/current-route (compassus/get-reconciler app))]
(when-not (= handler current-route)
(compassus/set-route! app handler {:params {:route/params route-params}}))))
(def history
(pushy/pushy #(set-route! %)
(partial bidi/match-route bidi-routes)))
Then the app-state will have a :route/params
key that I can access in my parser.Thanks @danielstockton. I also need the query to go to a remote. Would you then manually manipulate the ast that goes to the remote?
Yep, that's what I'd do.
To be clear, you don't need to define IQueryParams and add it to your query, like in the above example. You just pull it out of app-state in your parser and add it to the ast. Presumably, you'll get the id passed to your component anyway with the :db/id read.
My first instinct was also to use IQueryParams but it doesn't work, there is no way to pull things out of app-state. Those values should be static defaults and updated at runtime.
In Clojure (not ClojureScript), how can I check that a given component implements a protocol? I have a question (asked there http://stackoverflow.com/q/42349927/1327651) regarding om next *Clojure* protocols. Example:
(defprotocol my-protocol
(aaa [this] ""))
(defui MyComp
static my-protocol
(aaa [this] []))
(satisfies? my-protocol MyComp) ;; false
(satisfies? om.next.protocols/IReactChildren MyComp) ;; false
Scanning through the source, seems like the intend is to support it (?)
https://github.com/omcljs/om/blob/master/src/main/om/next.cljc#L332-L339I guess what I am asking is: is there an equivalent of implements?
in clojure for om.next components?
Seems like there are similar things there 😕 https://github.com/ladderlife/cellophane/blob/f27c9d48ceaf3c1a7522207a8dca898e0e149ea2/test/cellophane/next_test.clj#L33-L36
Actually I don’t care specifically about protocols, is there a different way to extend component behaviour with om?
I have been reading docs and playing with a sample app to better understand what gets re-rendered following a transact!
, with and without follow-on reads.
My current understanding is that:
a) In a transaction with only a mutation (eg '[(age/inc)]
)
• the component referenced by the transaction will be rendered, along with any of its children whose properties have been changed.
• if the component referenced has an ident, then any other component with the same ident will be re-rendered
b) In a transaction with a mutation and follow-on read of an ident (eg '[(age/inc) [person/by-name "tom"]]
)
• as above for a)
• in addition, any component with the ident in the follow-on read will be rendered, along with any of its children whose properties have been changed.
c) In a transaction with a mutation and a follow-on read of a keyword (eg '[(age/inc) :insurance/premium]
)
• the Root component will be rendered, along with any children in the component tree whose properties have been modified.
Although c) works fine, I was expecting the same optimizations as in a) and b) in that the rendering would only be performed on the components explicitly referenced by the transaction and follow-on reads.
Can anyone correct me if my understanding of a), b) or c) is wrong, and if it's not, point out why in case c) just rendering the components which use the keyword in their query would not be correct?
@craigmalone one other thing you might want to try is ’[(age/inc) [:insurance/premium _]]
@craigmalone I think you may be jumping to a conclusion on c) too fast
@chris-andrews The case I was testing with something like '[(age/inc) :insurance/premium] was updating a node lower in the UI tree, where the keyword is not a top-level key.
My understanding of the '[(age/inc) [:insurance/premium _]] ident follow on read is that :insurance/premium
would have to be a top level key (or at least supported as such by your read functions)
what actually happens (in the om.next/transform-reads
function) is that Om Next will try to find the complete query for the key you passed as the follow-on read
@anmonteiro I saw that, which results in a correct read/set of read for the key.
But then when it puts a set of components or keys in the :queue
for reconcile! to process for rendering, it is always using the top key of the query returned by om.next/transform-reads
which then always resolves to the parent component for an update.
@anmonteiro Sorry I meant "Root" component not "Parent" component.
hrm interesting
that might be right, yes
@craigmalone do you have a minimal example I can look at?
it's probably just an oversight that we can fix easily
@anmonteiro I can put the sample app up in github and give the link. It's pretty small.
I also played around with a minor change to transact*
locally, where instead of the putting the top level key of the resolved full query in :queue
I put the original follow on read keywords, and this gives the selective update behavior I was expecting.
I will add that to the github readme if it helps.
@craigmalone you can probably do that with :easy-reads true
in the reconciler
please make the example as minimal as possible thanks
Anybody use alandipert's storage-atom ? https://github.com/alandipert/storage-atom
@anmonteiro When you get the time, I have put the sample app in https://github.com/craigmalone/om-mutation-sample. Thanks.
@craigmalone sorry I'm not gonna look at that
that's not a minimal example at all
I know what the issue is, you can make a 25-line example showing it off
@anmonteiro OK, sorry, I will reduce it and update.
thanks!