This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-28
Channels
- # aatree (3)
- # alda (8)
- # avi (21)
- # beginners (37)
- # boot (193)
- # cbus (1)
- # cider (29)
- # cljs-dev (8)
- # cljsjs (3)
- # cljsrn (20)
- # clojure (76)
- # clojure-dev (13)
- # clojure-miami (20)
- # clojure-portugal (2)
- # clojure-russia (220)
- # clojure-sg (2)
- # clojurebridge (5)
- # clojurescript (94)
- # community-development (14)
- # conf-proposals (110)
- # core-async (12)
- # cursive (12)
- # datascript (6)
- # datomic (14)
- # dirac (72)
- # emacs (49)
- # hoplon (86)
- # jobs (33)
- # jobs-discuss (1)
- # ldnclj (6)
- # lein-figwheel (1)
- # off-topic (56)
- # om (139)
- # onyx (29)
- # pedestal (17)
- # proton (23)
- # re-frame (45)
- # reagent (35)
- # ring-swagger (4)
- # test-check (1)
- # testing (8)
- # yada (11)
Apart from this gist which doesn't seem to work as intended, I can't find many examples of using secretary w/ om-next https://webcache.googleusercontent.com/search?q=cache:lWqltnThWUIJ:https://gist.github.com/24ba8c404708c452b0de+&cd=3&hl=en&ct=clnk&gl=ca
@samueldev: AFAIK, routing is still evolving for om.next. Here is the design document https://github.com/omcljs/om/wiki/Routing-Support. Here is one example https://github.com/andrewboltachev/omnext-routing-one/ but it does not use secretary.
hi guys, what is the best way to embed global state like jwt token in every request ? I can see that om only takes care of the query. So the best way would be http header then ?
Are there any examples of the components (their ident and query methods) and denormalized data to make a table view? I am struggling with how to structure two locations and four gases. The table view I would like to see has gases along the top and locations down the left side. One way of thinking about the data is that there are two master-detail relationships: location->cell and gas->cell. Obviously the cell is the location/gas combination and there are eight of these. The first thing I'm trying to get right and failing at is automatic normalization (I can see the result with (pprint @reconciler)
). I can put together a gist of what I'm been trying, but this is such a common thing to want to do I'm hoping there might be an example out there already.
@cjmurphy: please put up a gist. I want to find out how this should work too, haven't played with ident yet
finally playing with db->tree
; any obvious reason this isn't denormalizing? https://gist.github.com/jlongster/bd88d9199a362677dbb3 (ignore the :list/transactions nil
bit)
@jlongster: I were looking at it some time ago. Let me check
@jlongster: thanks for explaining the part of process-roots btw
@jlongster: For me worked only this way:
om-ui.core=> (om/db->tree '[*] (:list/transactions (:transactions @reconciler)) @reconciler)
[{:from_acct [{:balance 0, :id 4, :name "income"}], :id 1, :to_acct [{:balance 0, :id 1, :name "bank of america"}], :amount 3.5, :date 1453243176928} {:from_acct [{:balance 0, :id 4, :name "income"}], :id 2, :to_acct [{:balance 0, :id 2, :name "chase"}], :amount 7, :date 1453243176928} {:from_acct [{:balance 0, :id 4, :name "income"}], :id 3, :to_acct [{:balance 0, :id 3, :name "credit"}], :amount 12.1, :date 1453243176928} {:from_acct [{:balance 0, :id 4, :name "income"}], :id 4, :to_acct [{:balance 0, :id 1, :name "bank of america"}], :amount 9.44, :date 1453243176928}]
Is there's a way to define if particular bound query (with QueryParams applied) is "instance" of unbound one?
@tawus: I have improved my routing example so that it uses core.async
channel and componentDidMount
event/method inside which set-query!
works properly (inside Om Next there's binding
in play, and thus set-query!
acts differently in different places).
It still uses one hack, this one: https://github.com/andrewboltachev/omnext-routing-one/blob/master/src/cljs/omnext_routing_one/core.cljs#L96
This is fake key (which readf
would just return nil
for) which is used to identify component by it's query. For a reason, metadata can't be used here (to do the same).
@jlongster: this is the general pattern of an om/db->tree
(om/db->tree query (get @state key) @state)
Let's say you want the :from-account
with the state from your gist.
query = [:from-account]
(get @state key) = (get-in @reconciler [:transactions :list-transactions])
@state = @reconciler
Applied to your gist:
(om/db->tree [:from_acct] (get-in @reconciler [:transactions :list/transactions]) @reconciler)
The docs say: `Given a query, some data in the default database format, and the entire
application state`. How I remember it: the 'default database format' has to be a function which returns something in the format
[[:transaction/by-id 1] [:transaction/by-id 2]]
The query pulls everything it specifies, after the 'default-database-format' aka [[:transaction/by-id 1] [:transaction/by-id 2]]
has been replaced with it's ident.When using update-query
to set the query params on a subcomponent, is it expected to trigger a root render? And thus also resetting the params to the initial, static values?
(I researched the chat history and closely related issues popped up repeatedly, however, I was not able to figure this out.)
@nblumoe: I were experiencing suchlike things (setting to initial values). Where are you using it from?
i.e. from render
or somewhere else?
well, just calling update-query!
from a click handler (on a button within that rendered component)
what's 1st parameter?
this
or MyComponent
?
oh well that's legit then
I were calling set-query!
from outside and it worked stange
ok, so that's expected behavior? I should instead call this how to make it re-render only that instance?
I did mean that it wouldn't necessarily not work then
Man, I'm really struggling with routing. My UI is completely build bottom-up, more like tinkering small components into a structured whole. Routing on the other hand is top-down.
@iwankaramazow: you can try out this approach of routing through this template https://github.com/anmonteiro/aemette/
Thanks, didn't know it existed 😄
I could get my queries with params on a subcomponent to work by using subquery
instead of get-query
. However, still the Root component is being re-rendered on every change on the subcomponent's query params, which I would like to avoid. ;(
If it does, perhaps path optimization could help here? Note: this is just me guessing, it may not actually help at all.
any more specific pointers what you mean with path optimization and how it could be related?
If a component has an ident and :pathopt
is enabled, it allows you to run queries against that ident/component independently of the root query. Normally, you would only get new props for the component by re-running the root query (e.g. after transactions) and passing the new props down. With path optimization, for idents like [:item/by-id 5]
, there would be a (defmethod read :item/by-id ...)
function and it would only re-run that where possible. I'm not 100% sure how good/accurate this explanation is.
The reason I was thinking it might be useful: if it would only re-run the [:item/by-id 5]
query when doing update-query!
it would not rerender your whole app. I'm not sure if it works that way though.
@nblumoe: There's no documentation for this yet but there is a devcards example and a test for the :item/by-id
read "shortcut" in the Om repository.
@nblumoe: I've only used it in one experiment so far: https://github.com/Jannis/custard/blob/master/src/web/components/nodes.cljs#L42 - here I have a component that represents [:node <ID>]
and whenever the transaction to expand/collapse the node, only read :node
is re-run, not the entire root query. This speeds things up quite a bit.
hi I'm trying to use OM together with SVG , this project is the blueprint im using: https://github.com/Hendekagon/hello-om-svg/blob/master/src/hello_om_svg/ui.cljs#L2
@dnolen: regarding #592, there's an alternative way: in factory
, add a reactKey
to props and read that in the react-key
function
@anmonteiro: yes something like that is preferred
@dnolen: I tried that first but thought that reading directly from where it was in React would be preferred
now I defined a new component for a hexagon which look slike this: http://pastebin.com/KKvACWQ8 but when I try to run it I get a this: WARNING: Use of undeclared Var hello-om-svg.ui/polygon at line 20 src\hello_om_svg\ui.cljs and the component doesn't show up
mea culpa
@anmonteiro: accessing into internals is just a huge pain in the butt
@dnolen: that becomes clear now, I'll do it another way then
btw is there something pending about #436 or did you just forget to close it?
@anmonteiro: link?
@anmonteiro: ah, thanks, just missed that one
@iwankaramazow: ah, of course thanks. you can also query from the top and just pass in the top-level state to both args (om/db->tree '[{:transactions [{:list/transactions [:from_acct]}]}] @reconciler @reconciler)
.
@dnolen: alright, just submitted #594 which uses the alternate approach
Here's an example of [*]
not working, what am I doing wrong?
galleon.reconciler=> (om/db->tree '[{:transactions [{:list/transactions [:amount :id]}]}] @reconciler @reconciler)
{:transactions {:list/transactions [{:amount 3.5, :id 1} {:amount 7, :id 2} {:amount 12.1, :id 3} {:amount 9.44, :id 4}]}}
galleon.reconciler=> (om/db->tree '[{:transactions [{:list/transactions [*]}]}] @reconciler @reconciler)
{:transactions {:list/transactions [{} {} {} {}]}}
@jlongster: Om queries != Datomic/Datascript pull queries.
@jlongster: Have you tried just [{:transactions [:list/transactions]}]
? If that doesn't work you'll have to specify a query for the :list/transactions
join. It can be recursive and/or come from another or the same component of course.
@jannis just tried it, it doesn't denormalize it. so there's no way to get all fields of a list of normalized data? I could have sworn I've seen [*]
in some tutorials. Not a big deal, I'm just learning in depth right now, don't actually have a use case
@jlongster: [*]
should work
trying out your example now
@anmonteiro: I can make a gist for clear STR if you need it
@jlongster: I'd appreciate it, esp. a piece of data I can use with that query
@jlongster: so I'll just try it quickly in alpha 30 and let you know
@jlongster: working for me actually
@jlongster: there were some changes in db->tree
between alphas 28 & 30
@anmonteiro: ok, thanks. still doesn't work for me actually, weird. are you running master, or definitely 30?
@anmonteiro: ah yep I had to blow away my build dir to make everything recompile again, sorry
Just from the Kanban example code, the denormalized:
:lanes [{:id 10} {:id 11} {:id 12} {:id 13}]
, turns into:
:lanes
[[:lane/by-id 10]
[:lane/by-id 11]
[:lane/by-id 12]
[:lane/by-id 13]]
But how about if I wanted just one, say:
:secret-lane {:id 11}
I tried it and it doesn't give me an Ident, but stays as {:id 11}
that query syntax doesn't look valid
a vector doesn't do the job?
Making it a vector doesn't help. Seems like you have to use matching keyword names and :secret-key does not match anything.
:secret-lane is described in an ident
somewhere?
@jlongster didn't know you could query from the top. Interesting!
alpha30: why is BarChild's render method getting called here after the transact!? https://www.refheap.com/114181
In om.next (inside tony awesome tutorial), I am trying to understand the korks
argument of set-state!
and update-state!
. I tried the following :
(om/update-state! this [:checked] ;; tried also :checked
(fn [l]
(prn l) ;; nothing printed
(not l)))
;; the following two equivalent implementations work
(om/update-state! this #(update-in % [:checked] not))
(om/set-state! this {:checked (.. e -target -checked)} )
Alright had a look at the source (https://github.com/omcljs/om/blob/master/src/main/om/next.cljs#L566), I don't need that .
Hello, basic question ~ does om.next support more than one root component on a page? I have tried this and only the last component added gets updates and I see the docs mention "the" root.
because it should support adding multiple roots to the page, so long as you attach them to different elements
no, separate divs with individual ids ~ it's something I've done in the current om, quite handy.
I have only just started looking at om.next and may well have missed something - thanks for the confirmation that I'm not trying something unsupported.
The om.next doc for app-root reads "Return the application's root component." which implies either 1. there is only one root, or 2. one of the roots is special
I hope it does support multiple - I have used multiple roots so the page editor can position the active elements
So if you have one reconciler, then "application's root component" is accurate, because each reconciler has one root component, and your app only has one reconciler
but if you have multiple, then app-root
s doc string would read better as "Return the reconciler's root component."
(defn add-root! "Given a root component class and a target root DOM node, instantiate and render the root class using the reconciler's :state property. The reconciler will continue to observe changes to :state and keep the target node in sync. Note a reconciler may have only one root. If invoked on a reconciler with an existing root, the new root will replace the old one."
from observing the channel, having one reconciler per app is the approach it seems many people are taking
and using set-query! and some other things to change child-components inside that one root
I will have a play with a shared atom and focus more on the source for docs ~ thanks for that guidance.
three roots, three reconcilers, common atom seems to work ok with my little test app.
so I guess that is the way to go for the use case where you have multiple "standalone" components that can share the same state.
I guess the denormalisation a reconciler does is for the use of components under the same root.
just noticed that an error thrown from a parser’s read function will propagate to the environment running om, while an error thrown from a parser’s mutate function does not propagate. rather, it is caught by om and converted into the response from the mutation. does anyone know why this is the intended behavior? Is there a built-in handling mechanism for pulling out and re-throwing the error?