Fork me on GitHub
#om
<
2017-01-06
>
eugekev01:01:19

Is there a reference somewhere describing the current state of Om Now vs Om Next? I thought last year that the movement was towards Om Next but I see that work is actively continuing on the former AND the Om Now basic tutorial was edited as recently as Nov 13, but Om Next’s Quick Start was edited last on Sept 13.

anmonteiro11:01:04

@eugekev: there hasn't been work in Om (Now) for a while

anmonteiro11:01:16

I see how you may have thought that, given both projects live in the same repo. See here for more context: https://github.com/omcljs/om/issues/765#issuecomment-246989800

eugekev13:01:40

Much thanks @anmonteiro - exactly the clarification I was looking for. Must also add: I find om next much easier to grok given some JavaScript react experience I have. Great thanks to all devs

peeja16:01:55

Hey, all. I'm trying to make a button that transacts a mutation on-click which goes to the remote server, but I'd like the button to show a "Working…" state until the mutation succeeds (or fails) remotely. Are there any good patterns for this yet?

peeja16:01:47

I can imagine ad hoc ways of doing it by adding a key somewhere in the local implementation and removing it when the request comes back, but I'd like to come up with something that doesn't require recreating a bunch of moving parts each time I want to use it.

hlolli16:01:53

Id love to hear a good way to do it too. I solved it by transacting in the app state loading to true on click, and the server response has {:loading false} that merges, causing a accurate loading indicator. But the ugly thing about this is that Im sending {:loading? false} across the wire for seemingly no good reason.

sova-soars-the-sora17:01:45

Hmm... I have seen some patterns but nothing that really strikes me as "the way to do it" ... Basically a loading message while waiting on the mutation? How do you have your mutations re-integrate into your app?

sova-soars-the-sora17:01:57

@ag just out of curiosity, did you figure out how to parse next-props ?

sova-soars-the-sora17:01:16

does anybody have a good resource on what the funky chicken is going on with including cljc files among cljs/clj ?

ag19:01:44

> did you figure out how to parse next-props ? @sova nope ;(

drcode19:01:50

@peeja @hlolli The closest comment from Nolen on this is here: https://github.com/omcljs/om/wiki/Om-Next-FAQ#how-can-i-delay-loads Likely your client will receive something from the server after the button is done working (a database id for instance) wherever that data is stored in the client state, place a :loading marker and then have the UI reference that marker to display the loading message. The marker will be overwritten once the server data has arrived. (still a bit ugly, I agree)

peeja20:01:47

@drcode I've seen that, but I'm not sure there's a great way to make that approach work. For one thing, that means any time I put a button in my UI, I have to compose its query into whatever component it's rendered in, and I have to make up a key for that query to live under.

drcode20:01:05

@peeja- Yeah, I agree it's messy... I suppose what's needed long term is a way to query the remoting process in some abstract way so you can ask it "what is the status of the remote request associated with this transaction?"

peeja20:01:25

Oh, that's interesting.

peeja20:01:07

It still means composing the query of each button into its parent's query

peeja20:01:21

and making up a bogus key for it

peeja20:01:16

It's frustrating that a component which is only ever going to use idents for its query, and therefore has no logical place to be nested in a larger query, still has to be "mounted" in the query tree under some bogus key

drcode20:01:15

@peeja I've given up on the idea that queries should be tidy. Instead, my rule now is that queries are super messy, but the parsers can use arbitrary transformations to insulate the app state from the messiness, and as long as the app state is clean, who cares if the queries are messy?

peeja20:01:14

Well, considering the query represents a data model that lives across multiple codebases and servers, I care. 🙂

peeja20:01:40

I mean, that's overstating it a bit: it just means that it's the local parser's job to clean that up before passing it on

peeja20:01:47

but that cleanup is getting harder and harder to do

drcode20:01:16

@peeja I guess I consider the query to be a sort of "View" on the data (with all the messiness that views can have, due to UI idiosyncracies they have to serve, such as needing to display highly specific info in a otherwise very general button)

drcode20:01:29

@peeja but yeah, I struggle with OmNext queries on a regular basis... this stuff is hard.

peeja20:01:37

Yeah, I guess that makes some sense

ag22:01:45

Guys, need help. Still can't figure out the normalization stuff. My head is exploding. If I have state data like this:

{:app/data [{:id :foo, :table/data [1 2 3]}
            {:id :bar, :table/data [4 5 6]}]}
and after setting the idents and then when I run (om/tree->db Root init-data true) it returns:
{:app/data       [[:table/by-id :foo] [:table/by-id :bar]]
 :table/by-id
 {:foo
  {:id :foo
   :table/data
   [1 2 3]}
  :bar
  {:id :bar
   :table/data
   [4 5 6]}}
 :om.next/tables #{:table/by-id}}
now running this:
(om/db->tree '[:app/data] (om/tree->db Root init-data true) reconciler)
returns something like:
{:app/data [[:table/by-id :foo] [:table/by-id :bar]]}
- But how do I grab table/data for specific table? What is the syntax of the query will be? - Can I expect to be able to grab that data without having to implement read method for :app/data? just by using om/db->tree?

ag22:01:30

what is the map-ident argument in db->tree? how can I use it?

anmonteiro22:01:29

@ag your problem is that the query is not specific enough to denormalize the data

anmonteiro22:01:48

if you ask Om Next to denormalize a single property, it'll just return that property to you

anmonteiro22:01:13

try this:

(def normalized (om/tree->db Root init-data true))
(om/db->tree (om/get-query Root) normalized normalized)

anmonteiro22:01:54

there needs to be a join for Om to look past the single prop

ag22:01:40

I understand. What I can’t figure out how to use “reference” syntax in join query so this returns the right thing, but it returns it with both :id and :table/data of :foo

(om/db->tree '[{:app/data [[:table/by-id :foo]]}] @reconciler @reconciler)
How do I force it to grab only :table/data of :foo?

anmonteiro22:01:55

@ag maybe (om/db->tree [{:app/data [:table/data :id]}] [:table/by-id :foo] @reconciler)

anmonteiro22:01:12

an ident if effectively a piece of data, which you can pass as the 2nd argument to db->tree

ag22:01:44

ehhh… what…? oh… eh… mkay

anmonteiro22:01:25

if you pass the full app state as the 2nd arg of db->tree it can be potentially very slow

anmonteiro22:01:33

as it'll denormalize the entire state everytime

ag22:01:37

I don’t think it’s working (approach you suggesting), maybe I am missing something else

anmonteiro23:01:23

@ag my bad, try this instead:

(om/db->tree [:table/data :id] [:table/by-id :foo] @reconciler)

anmonteiro23:01:47

you don't need to put :app/data in the query, of course, since you just want a single item

anmonteiro23:01:52

so use the query which describes it

ag23:01:25

alright that worked

ag23:01:51

but I’m more confused to be honest even more than before

ag23:01:24

Thanks Antonio!

anmonteiro23:01:01

what don't you understand?

ag23:01:24

no, no, I was just totally surprised by db->tree arguments

ag23:01:16

now it totally makes sense

ag23:01:32

I’m still a bit befuddled I guess

ag23:01:36

God, I wish someone wrote a book on OmNext that explains its mechanics