the field holds the ident of the item that is being edited
so when that field gets set to some ident, the component renders a child component through which the entity is supposed to be edited
Now I'm having trouble defining the query of this child component
Because my presumption is that I can somehow resolve this ident within this child component
I hope it's somewhat clear what I'm asking
I'm implementing a drag/drop within SVG. Within the untangled/om-next model, how is this to be done? The thing that confuses me is: while the mouse button is held down, anad the mouse is being moved, what queries should I be firing off?
@qqq: My experience is that its not great to use app state to store something like current mouse position - its too slow. Best to use local state. There's an example of using local state in the cookbook recipies.
@cjmurphy: yeah, recording every mouse movement is not particular useful
I guess local state until mouseUp, then when window ahs dropped, record the new x/y coordiantes, but not the intermediate mouse movements
Sounds good, esp if those coords are needed by the rest of your app.
so I'm simulating a basic desktop with windows
when the user closes the browser and re-opens, I want the windows to be in the same place
Definitely in app state then.
what is the right place to attach "validation" functions? so for example, suppose I have a defui which has an input box in one case, I only want valid phone numbers in another case, I only want valid zip codes in a third case, I only want multiples of 3 so now I have a function which is of type "String -> Bool" how do I parameterize a defui with this function?
I guess https://github.com/omcljs/om/wiki/Documentation-(om.next)#factory validator
The above is where the validation functions are. Clone that repo and read about them.
what? that has to do with ui
there is a :validator tag in om/factory, but for what I need -- it's more callback ish, andI need om/computed instead
Question about using the router (0.7.0 client code) - I have a message list that I am loading on scroll from server to client and the post mutation for this involves appending the new message/by-id records from a load cache to the message lists data structure. When I place the message list under the router, am I correct in thinking that the existing mutation then needs to know about the changed location of the message list records being held under the router structure or am I missing something?
Ignore the above - I think I've worked it out, my message list component needs an ident and then I can reference it correctly from the mutation by passing this ident through!
@urbank Don't mistake core.spec as a replacement for anything. It is a new capability. Another tool in the toolbox. Untangled spec is a set of wrappers around clojure/cljs.test that make testing a bit simpler in terms of what you have to write/read.
@lucasbradstreet @sova thanks! Hope I don't disappoint 😉
@urbank on your question about queries. It is not particularly clear. I'd recommend watching the getting started videos. Many people have found them helpful in getting an understanding of things.
@tony.kay Ok, I'll watch the videos again to see if there's an answer in there.
If you've watched them, then clarify your question
I don't want to put you off, just want to optimize my time
best to give a simple example of a database as a data structure, and the query you're trying to do
but strip it down to bare minimum
@cjmurphy Just FYI I am pushing (alpha-quality) SNAPSHOTs of that to clojars
Yeah, I wasn't put off. I can see how that tone was implied 🙂 Was just going to watch them again, because I sometimes see new things when rewatching with new knowledge
So, basically I'm coming here from trying out datascript with posh, where a database can be arbitrarily queried from a component. So I probably have some incorrect intuitions that don't apply to om/next / untangled. Anyway, an example:
Yes, a component in Om Next will mainly query what makes sense in the context of that component (as if the state were local to it). The link queries are very rare, and should typically be reserved for asking for global singleton things, like current user.
I mean, you can do what you want, but I don't recommend trying to use the query language as a general purpose datascript query language.
at least in terms of "decoupled from UI".
the joins in the Om Next db format (idents) will be followed by joins in the query. So you can make it work. But you only get auto denormalization from a server if there is a component at every join
because that is how idents (for the joins) are defined
you mostly should not have to think about idents when working with render
only inside of mutations and incoming data normalization
And you can use defui to just define queries/idents (no UI). So, you can do more complex things that way.
(and an example is still ok 😉 )
Yeah, still making one 🙂
@tony.kay Hah I think I got it! Trying to formulate a question seems to help often 🙂
So apparently I was ignoring om/Ident . If I define an EditItem component with an ident pointing to items/by-id and give it the same query as ItemRow, it resloves correctly. I also need to compose the query of EditItem into ItemsTable
`[:table/type {:editing (om/get-query ItemEdit)} {:items (om/get-query ItemRow)}]
Now, so far all my components have idents... so that might be a red flag given what you wrote above (if I understood it correctly)
Or perhaps I'm just defining the parts of my application which actually need idents
Oh wait, 😳 . The ident doesn't matter actually
So that's even better
So I suppose something about queries confused me.
`[:table/type {:editing (om/get-query ItemEdit)} {:items (om/get-query ItemRow)}] <- So :editing resolves to an Ident [:items/by-id 1] whereas :items remains :items ... it doesn't resolve into [[items/by-id 1] [items/by-id 2]]
oh wait it does, doesn't it
it just has 'cardinality many' ?
if so, it's all clear 🙂
@urbank formulating the question correctly is what's up.
@urbank Yes, :editing resolves to an ident because you've queried it as an abstract scalar property
:items is queried as a join, so you should see the real items (e.g. it should follow the idents and give you back the objects with just the sub-properties that the item queries ask for)
nothing really more to it 🙂
that covers like 90% of what you need to know
@tony.kay Cool, that's clear then! I feel a lot more at home with it now. Thanks! 🙂
no problem
what's the status of defuitools?
do you guys use it? does it do anything super useful?
any docs
So, there is a defui in untangled that allows you to hook into components.
There are some examples in the source itself
not currently used, but will be whenever we get time 🙂
kk, thanks
reading the source
would be nice if you could alt-click a DIV and see it's props, or something
agreed. That is possible with that support
it also has dev/prod mode switching, so you can instrument just in dev