Fork me on GitHub
#om
<
2016-09-27
>
raspasov07:09:30

hey guys - is there a way to set a static property on an om.next component defined via (defui ... ) ?

raspasov07:09:42

it requires static "route" property on a component

alex-glv07:09:06

Are there any examples using om.next with other than datomic back-end? I imagine one has to adapt reads/mutations and basically translate queries?

alex-glv07:09:52

Feels a bit overwhelming if you’ve never used either datomic or om.next before and having to learn both at once, I’d like to try a db I’ve used before.

alex-glv07:09:16

FWIW the tutorials seem very good though, went through a couple and was able to get up and running with simple apps like AnimalsList etc.

levitanong08:09:11

@raspasov Have you tried just putting in there? @anmonteiro just added a fix that allowed arbitrary static protocols to be added to a defui class.

levitanong08:09:59

oh wait, hmm… props...

levitanong08:09:53

okay scratch what I said

raspasov09:09:31

@levitanong yea : ) but thanks

anmonteiro10:09:18

@raspasov:

(defui MyComponent
  static field foo 42)

anmonteiro12:09:43

but if you want that to be merged, you must ask @dnolen to sign a CA

anmonteiro12:09:08

unless you’ve done it already?

levitanong12:09:50

@anmonteiro Sent him an email 🙂 Awaiting his reply

levitanong12:09:05

I do hope it hasn’t been sent to his spam folder

anmonteiro12:09:27

I wonder if https://github.com/omcljs/om/wiki/Contributing shouldn’t be in the root of repo

anmonteiro12:09:41

in a CONTRIBUTING.md or something

anmonteiro12:09:47

would probably be easier for people to find it

levitanong12:09:28

i personally don’t find a problem with it being in the readme

levitanong12:09:35

though I can see why other people would look for it in CONTRIBUTING.md

anmonteiro12:09:44

oh it is in the README?

anmonteiro12:09:05

well not really

anmonteiro12:09:14

it’s not the same information

levitanong12:09:50

LOL okay I only just found the wiki entry now

anmonteiro12:09:21

^ I rest my case

hlolli13:09:53

js->om question. this.refs.item.focus() = (.focus (.-item (om/react-ref this :some-ref))) ?

anmonteiro13:09:07

@hlolli should probably be: (.focus (om/react-ref this “item”) )

hlolli13:09:54

yes, when its a string this works, at least now I have a new error message that is out of the scope of om this.input.getInputNode is not a function material-ui.inc.js:27365 thanks, for this!

peeja15:09:23

Suppose my component needs to render a subcomponent which will render the current user. My component queries for [{:app/current-user (om/get-query User)}] and renders (user (:app/current-user (om/props this))). Now suppose my component also needs to show the name of the current user elsewhere in its UI. How do I query for both? I don't believe I can just query for [{:app/current-user (om/get-query User)} {:app/current-user [:user/name]}]. That appears to just use the second join.

peeja15:09:29

Is there a way to do what I'm asking for?

peeja15:09:57

I'm guessing there isn't, as I don't know how the :om-path metadata would work

peeja15:09:15

but I'm not sure how to accomplish what I'm trying to do

anmonteiro15:09:59

@peeja why isn’t putting :user/name in the query of User an option?

peeja15:09:21

Because, in this slightly contrived example, User doesn't actually need the :user/name

peeja15:09:44

Imagine it's something a bit more esoteric than the user's name 🙂

anmonteiro15:09:57

@peeja so (into (om/get-query User) [:user/name ]) should work

peeja15:09:10

Oh, yeah, that should work

anmonteiro15:09:23

you just need to be careful to keep the query metadata

anmonteiro15:09:32

which is why I didn’t write (into [])

peeja15:09:47

I assume I'll run into trouble if I have two components that need to render the :app/current-user from here

peeja15:09:00

but luckily I only have the one subcomponent in my case

peeja15:09:21

It would be nice to be able to alias/project keys in a query

peeja15:09:08

Something like [{[:app/current-user :as ::user-for-subcomponent] (om/get-query User)} {:app/current-user [:user/name]}]

peeja15:09:28

(Obviously the syntax can't be a vector there, because that looks like an ident.)

peeja15:09:39

(Although, it has three elements instead of two…)

anmonteiro15:09:51

@peeja nothing stopping you from giving another name to the join?

anmonteiro15:09:01

maybe I don’t understand your use case

peeja15:09:10

Well, I don't want the parser to be interested in the name of the key

peeja15:09:13

It's a component concern

peeja15:09:46

I want to tell the parser, "Read :app/current-user, but return it to me as ::user-for-subcomponent"

peeja15:09:22

Just as you don't need to permanently alias tables in a SQL database to give a table an alias within a query

anmonteiro16:09:40

@peeja I really might not be getting your use case, but that’s also something you can do in the parser

peeja16:09:00

Yeah, actually, I probably can

peeja16:09:15

Oh, well, I'd need to rebuild the whole parser (or wrap it)

peeja16:09:29

The read can't change the key that the result comes back under

anmonteiro16:09:30

“parse this query here, put the result that’s under :foo in the response under :bar in my result"

peeja16:09:51

Also, I'd need to rewrite db->tree 🙂

anmonteiro16:09:56

if it’s a top-level property probably not

anmonteiro16:09:09

i.e. you probably can’t do what I said

anmonteiro16:09:20

if it’s not you can use recursive parsing

peeja16:09:45

Yeah, I might give this a try

peeja17:09:43

@anmonteiro If I just into it, I'll lose the additions if my subcomponent set-query!s, right?

raspasov20:09:42

@anmonteiro I was trying to read the defui macro code but couldn't quite get that part within 15-20 minutes, thanks again! : )