Fork me on GitHub
#om
<
2016-10-13
>
ag00:10:32

oh I just realized how stupid my question is. you can’t see the result of parametrized query until it’s passed to parser, right?

herbm01:10:05

In a clojurescript figwheel REPL what namespace has the "use" command -- I can't use swap! or even use and need to use the right namespace to get something workable

molstt10:10:57

could someone possibly give a more detailed description of the relation between 'some-data' and 'app-state-db' in the db-tree docs? https://github.com/omcljs/om/wiki/Documentation-(om.next)#db-tree

anmonteiro10:10:01

@molstt sure. the app-state-db is the entire app-state where db->tree will look when resolving idents & links

anmonteiro10:10:16

the “some-data” parameter is the subset of data that you want to denormalize

molstt10:10:39

ok, thanks!

anmonteiro10:10:48

(it can be a single ident)

anmonteiro10:10:06

(om/db->tree [:foo/name :foo/other] [:foo/by-id 0] app-state

anmonteiro10:10:47

would probably return:

{:foo/name “Foo”, :foo/other “some other value"}

anmonteiro10:10:28

given that your app-state contained:

{:foo/by-id
 {0 {:foo/name "Foo", :foo/other "some other value"}}}

alex-glv10:10:34

I think I started grokking readers. It was really tough to comprehend what’s the flow of data like deeper into the query from root to children and bubbling back up. Will write a blog post hope it’ll help some others. The existing docs are good once you start getting it, but definitely for people who are very comfortable with cljs.

alex-glv10:10:48

@anmonteiro some good stuff in your posts, @tony.kay also very helpful resources with om-tutorial. Definitely needs to go into “unofficial” docs section somewhere in wiki.

molstt10:10:25

ok, so it is a selector rather than "some-data"... will try it out

molstt10:10:18

but isn't it strange that @state is often supplied as "some-data" ?

anmonteiro10:10:06

@molstt if you pass your root query and want to denormalize the whole state, sure

anmonteiro10:10:18

I never actually do that though

anmonteiro10:10:39

the most common thing is to call db->tree like this: (om/db->tree query (get st k) st)

anmonteiro10:10:46

where k is the key your parser dispatched on

molstt10:10:22

mhm.. but (get st key) returns data from the database, while [:key 24] and :key are selectors.. isn't it two very different things?

anmonteiro10:10:30

@molstt (get st key) could return a selector 🙂

anmonteiro10:10:08

normally it’ll return an ident or a list of idents, yes

molstt10:10:30

ok, thanks, will have a look at it

rastandy10:10:36

@levitanong Thank you man for offering your help, I solved the problem with the text input that loses focus 😉

molstt11:10:33

@anmonteiro I almost got it working now, the thing I don't understand now is why a query like this {:my-view '[{:stuff [:info [:root-mud _]]}]} returns proper data twice [{...proper data...} {...proper data...}]

anmonteiro11:10:29

@molstt that’s not enough information for me to understand what might be going on, sorry

molstt11:10:22

ok, I will dig a little more first

anmonteiro11:10:53

@molstt happy to look at a particular example

anmonteiro11:10:10

something I can run at the REPL, for example

levitanong11:10:17

@rastandy glad you figured it out! 😄

molstt19:10:22

Is it intentional that remotes only have effect when added besides :value at the reads for the top level components and not for leaf components? I have a recursive read function with a multimethod dispatching on leaf components supplying {:value "foo" :my-remote ast} for one of the components, but the send function does not get called. When moving :my-remote to the retval of a top level read function, the send function gets called as expected.

anmonteiro20:10:58

@molstt that’s how it’s supposed to work

anmonteiro20:10:29

if you call your parser recursively, the function call returns to your parser, not to the Om function which will schedule the send function to be called

anmonteiro20:10:55

this might not be very straightforward to get at first, but it’s just like a recursive function call: the caller only sees the result at the top-level.

anmonteiro20:10:10

^ hope that makes sense. here’s an example of doing recursive parsing with remotes involved: https://github.com/awkay/om-tutorial/blob/master/src/main/om_tutorial/parsing.cljs#L191

molstt20:10:47

yes, I was just looking for that function.. saw a ref to it in https://awkay.github.io/om-tutorial/#!/om_tutorial.G_Remote_Fetch

currentoor20:10:38

I wrote an article about how we added real-time collaboration to our Om Next app. https://medium.com/adstage-engineering/realtime-apps-with-om-next-and-datomic-470be2c8204b#.ur111tdjp

kkruit22:10:56

I'm new to react and om. Is it common to have the root redraw every time the state changes. The issue is that I'm using material design light and "upgrading" some of the styles on componentDidMount which makes the active tab flash inactive whenever my state changes. I'm using omnext defui if that changes anything.

kkruit22:10:17

The "upgrade" changes the dom. Could that be why it's re-rendering?

ag22:10:46

@kkruit local state or global state? your question is too vague. I’m afraid you’re not gonna get meaningful help. I think you need to be more specific.