Fork me on GitHub
#om
<
2016-09-30
>
levitanong06:09:45

is it required that :keyfn be an integer? When prerendering an om.next app, when trying to pass to :keyfn a fn that returns either a keyword or a string, the compiler complains: java.lang.IllegalArgumentException: Key must be integer

levitanong06:09:18

oops, scratch that

levitanong06:09:20

I’m being stupid

alex-glv06:09:46

Does every entry in the om next query cause call to read with the entry as the key? Eg I want to have UserList and a User, what's the best way to fetch the data from remote? Define :user/list read key? Is there a definitive guide on the query expressions and read, or is it mostly blogs and wiki pages?

levitanong06:09:22

@alex-glv Generally, only the individual queries of the root component will trigger reads in the parser.

(defui ChildComponent
  static om/IQuery
  (query [this]
    [:child-query1 :child-query2])) ;; these don’t trigger reads

(defui RootComponent
  static om/IQuery
  (query [this]
    [:query1 :query2 {:join-query (om/get-query ChildComponent)}])) ;; Generally, compose all subqueries into root query.
;; triggered reads are: :query1 :query2 :join-query

levitanong06:09:56

I would place the remote query in the :user/list read key.

levitanong06:09:15

I don’t think we’ll have a definitive guide until om.next settles down into not-alpha. In the meantime, this is a very good resource: https://anmonteiro.com/2016/01/om-next-query-syntax/

alex-glv06:09:24

Awesome, thanks!

gardnervickers15:09:43

Is it ok to have ident’s on the components in a union?

iwankaramazow15:09:39

@gardnervickers: I think it's a requirement for a union query

niamu17:09:27

Anyone have any experience writing Om components and using them within a JavaScript project?

niamu17:09:35

The best strategy I have at the moment is to have the JavaScript project create a new div as an injection point for an Om root. This would involve have a React root (built with Om) inside of another React root (built by the top-level JavaScript project).

grzm20:09:45

what approaches have people been using for mocking the parser in testing the ui? I'd like to do some browser-based testing and want to test the parser logic, but don't want to set up a backend to handle remotes.

anmonteiro20:09:15

@grzm you don’t need to setup backends

anmonteiro20:09:35

the parser never sends anything to the remote

anmonteiro20:09:08

the result of parsing something in “remote mode” is a query expression

anmonteiro20:09:10

not a remote call

grzm20:09:56

So when I create a reconciler, I just leave the remotes empty and it should all be good?

anmonteiro20:09:27

depends on what you want to test

grzm20:09:56

lol. At this point I want to make sure I haven't broken mutations when I do refactoring/code updates. Like when I click a button that triggers a transaction I'm getting the appropriate state change.

anmonteiro20:09:36

what I meant is: you can test remote interactions, and if you want to do that, you don’t want to leave remotes empty in the reconciler

grzm20:09:42

So I guess there are two things: one is that the components are rendering properly, and that the mutations work

anmonteiro20:09:44

you can e.g. have a different send function

grzm20:09:29

Yeah, right now I'm not worried so much about full-stack remote interactions.

grzm20:09:23

Okay, so it sounds like I should be looking at send

anmonteiro20:09:51

@grzm so one thing you might have not realized

grzm20:09:03

There's a lot I have not realized 🙂

anmonteiro20:09:06

is that you don’t need to assemble a reconciler

anmonteiro20:09:22

you can test that mutations work with only a parser

anmonteiro20:09:05

(def p (om/parser {:read read :mutate mutate}))
(p {:state (atom init-state)} '[(do/this!)] )

grzm20:09:31

And the result value is the updated state?

anmonteiro20:09:04

since the state is an atom you can have a reference to it somewhere and deref it for checking the result, right?

anmonteiro20:09:30

I don’t remember what the result of a mutation is from the top of my head

anmonteiro20:09:46

you’ll have to check it out for yourself 🙂

grzm20:09:19

You sure? I mean, you can just shell into my machine and do my work for me 🙂

anmonteiro20:09:56

@grzm sure, I’ll let you know my hourly rate 🙂

peeja22:09:56

I'm confused about this error, (str "No queries exist for component path " cp " or data path " path') https://github.com/omcljs/om/blob/3a8229c4a843c9978ced8eec94f0fa33ae57b869/src/main/om/next.cljc#L1962

peeja22:09:24

Shouldn't that be "and data path path'"?

peeja22:09:26

That error only comes up if at least one query is found for the class path, but none of them matches the data path.