Fork me on GitHub
#om
<
2016-05-13
>
mitchelkuijpers07:05:51

@mattyulrich: why not just create the ident with the id you have set as a value? and then get the value from the event like this (-> e .-target .-value)

mattyulrich10:05:30

But the value is a number, I can create the ident from that like [:class/by-id val] but once I have that, how do I extract the actual item from the db?

mitchelkuijpers10:05:52

If you set :selected-class to [:class/by-id val] you should automatically get back the new selected class because you call om/db->tree in your read function for selected-class

mattyulrich10:05:09

Ok - you’re right! When I did this before, it didn’t work because my id was coming in as a String, not a number.

anmonteiro10:05:12

see answer in your gist

mattyulrich10:05:47

Yeah.. Ok, that works great.

mattyulrich10:05:11

So - where is my id being converted to a String?

anmonteiro10:05:06

@mattyulrich: when you get it from the DOM node

anmonteiro10:05:09

it comes as a string

anmonteiro10:05:21

the option’s value property is a string

mattyulrich10:05:37

Ahh - ok, that’s a fundamental bit that I never put together before.. Thanks for the help!

anmonteiro10:05:39

I’ve inserted comments where I changed things

anmonteiro10:05:04

other thing you got wrong was having queries where they never made it to the root

anmonteiro10:05:06

I just removed those

mattyulrich10:05:07

Yup - I see your changes, I had something like this at some point but when I set the [:class/by-id val] it wasn’t doing anything because the val was a String..

anmonteiro10:05:45

@mattyulrich: other thing. if you notice, I’m using (.. event -target -options -selectedIndex)

anmonteiro10:05:58

depending on the browsers you’re targetting, this might not be the best approach

anmonteiro10:05:10

not every browser implements it, AFAIK

anmonteiro10:05:34

the other option is filtering the options for the one that has the selected property set to true

mattyulrich10:05:56

would it not just be good enough to use …. -target -value ?

anmonteiro11:05:00

@mattyulrich: pretty sure target value is not a thing in the select

mattyulrich11:05:05

btw, what you wrote in my gist with the computed props in the Class-Select really clarifies things for me… I’ve been really confused about where I need and don’t need to put the IQuery on my component.

anmonteiro11:05:06

or at least the thing you want

mattyulrich11:05:40

Ok - this was really helpful; thanks!

mitchelkuijpers11:05:01

target value is definately a thing in select and works in every browser. It returns the selected value as a string

mattyulrich12:05:02

Ok - thanks to all the help from you guys, I’ve updated my gist here: https://gist.github.com/mattyulrich/8524ce8f20606e644770205021875639

mattyulrich12:05:22

Everything works exactly how I think it should and I have a much better understanding of how om.next works.

mattyulrich12:05:30

I added in the simulated ajax calls to login and get the data associated with the user… so my initial app state now starts as an empty atom.

mattyulrich12:05:27

And cleaned up some more places where I really didn’t need an Ident/IQuery (around the Header bits; it’s much cleaner now)

mattyulrich12:05:40

In my mutation functions, I was able to perform the mutations from raw “server” data by using om/tree->db and merging the results into the state. It seems to work great and makes sense to me, but is this an idiomatic approach?

taylor.sando14:05:07

Anyone else think that the om parser would make a good separate library? It could handle api calls really well, especially calling different services and being able to reconcile them into a single response map at the end. One addition might be the ability to do async calls, like having a top level timeout that will run the parser until the timeout stops, and then return what it has up to that point.

anmonteiro14:05:35

@taylor.sando: atm the parser is very tied to the Om Next query grammar

anmonteiro14:05:46

what do you have in mind for relaxing such assumption?

taylor.sando14:05:04

I like the grammar as it is. It would be more about the implementation on how the parsing itself would be run

taylor.sando14:05:52

Could potentially be useful for om itself, if you wanted to guarantee 16ms parser times.

anmonteiro14:05:55

@taylor.sando: I like the idea having heard it just now. I also wonder if that couldn’t be a part of Om

anmonteiro14:05:05

i.e. why a separate lib?

taylor.sando14:05:01

I guess because you don't really need the reconciler and view logic if you wanted to use it simply as an API handler--though om isn't exactly large, and if it's on the server, I guess the added source code doesn't really matter.

anmonteiro14:05:36

@taylor.sando: that’s the reason of my question. code size doesn’t really matter on the server

anmonteiro14:05:50

atm anyways, Om on the server is just the parser implementation and the transit handlers

taylor.sando14:05:55

I guess it would also be separation of concerns. I like the om query syntax as an answer to graphql. It's a good message query syntax, especially when combined with transit.

iwankaramazow19:05:13

@anmonteiro: really loved your talk, just watched it 😄

blissdev20:05:35

is there a link to said talk?