Fork me on GitHub
#untangled
<
2017-02-27
>
urbank00:02:21

the field holds the ident of the item that is being edited

urbank00:02:37

so when that field gets set to some ident, the component renders a child component through which the entity is supposed to be edited

urbank00:02:56

Now I'm having trouble defining the query of this child component

urbank00:02:40

Because my presumption is that I can somehow resolve this ident within this child component

urbank00:02:02

I hope it's somewhat clear what I'm asking

qqq03:02:55

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?

cjmurphy04:02:10

@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.

qqq04:02:39

@cjmurphy: yeah, recording every mouse movement is not particular useful

qqq04:02:56

I guess local state until mouseUp, then when window ahs dropped, record the new x/y coordiantes, but not the intermediate mouse movements

cjmurphy04:02:32

Sounds good, esp if those coords are needed by the rest of your app.

qqq04:02:52

so I'm simulating a basic desktop with windows

qqq04:02:02

when the user closes the browser and re-opens, I want the windows to be in the same place

cjmurphy04:02:48

Definitely in app state then.

qqq10:02:23

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?

cjmurphy11:02:04

The above is where the validation functions are. Clone that repo and read about them.

qqq11:02:26

what? that has to do with ui

qqq11:02:40

there is a :validator tag in om/factory, but for what I need -- it's more callback ish, andI need om/computed instead

tobias13:02:15

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?

tobias15:02:07

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!

tony.kay16:02:19

@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.

tony.kay16:02:34

@lucasbradstreet @sova thanks! Hope I don't disappoint 😉

tony.kay16:02:37

@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.

urbank16:02:10

@tony.kay Ok, I'll watch the videos again to see if there's an answer in there.

tony.kay16:02:33

If you've watched them, then clarify your question

tony.kay16:02:42

I don't want to put you off, just want to optimize my time

tony.kay16:02:08

best to give a simple example of a database as a data structure, and the query you're trying to do

tony.kay16:02:20

but strip it down to bare minimum

tony.kay16:02:50

@cjmurphy Just FYI I am pushing (alpha-quality) SNAPSHOTs of that to clojars

urbank16:02:08

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

urbank16:02:29

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:

tony.kay16:02:17

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.

tony.kay16:02:44

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.

tony.kay16:02:05

at least in terms of "decoupled from UI".

tony.kay16:02:06

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

tony.kay16:02:14

because that is how idents (for the joins) are defined

tony.kay16:02:48

you mostly should not have to think about idents when working with render

tony.kay16:02:06

only inside of mutations and incoming data normalization

tony.kay16:02:32

And you can use defui to just define queries/idents (no UI). So, you can do more complex things that way.

tony.kay16:02:34

(and an example is still ok 😉 )

urbank16:02:19

Yeah, still making one 🙂

urbank17:02:15

@tony.kay Hah I think I got it! Trying to formulate a question seems to help often 🙂

urbank17:02:02

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

urbank17:02:54

`[:table/type {:editing (om/get-query ItemEdit)} {:items (om/get-query ItemRow)}]

urbank17:02:01

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)

urbank17:02:29

Or perhaps I'm just defining the parts of my application which actually need idents

urbank17:02:05

Oh wait, 😳 . The ident doesn't matter actually

urbank17:02:18

So that's even better

urbank17:02:27

So I suppose something about queries confused me.

urbank17:02:13

`[: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]]

urbank17:02:20

oh wait it does, doesn't it

urbank17:02:44

it just has 'cardinality many' ?

urbank17:02:51

if so, it's all clear 🙂

sova-soars-the-sora18:02:15

@urbank formulating the question correctly is what's up.

tony.kay18:02:15

@urbank Yes, :editing resolves to an ident because you've queried it as an abstract scalar property

tony.kay18:02:33

: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)

tony.kay18:02:18

nothing really more to it 🙂

tony.kay18:02:32

that covers like 90% of what you need to know

urbank18:02:44

@tony.kay Cool, that's clear then! I feel a lot more at home with it now. Thanks! 🙂

jasonjckn23:02:56

what's the status of defuitools?

jasonjckn23:02:08

do you guys use it? does it do anything super useful?

tony.kay23:02:51

So, there is a defui in untangled that allows you to hook into components.

tony.kay23:02:57

There are some examples in the source itself

tony.kay23:02:05

not currently used, but will be whenever we get time 🙂

jasonjckn23:02:42

reading the source

jasonjckn23:02:49

would be nice if you could alt-click a DIV and see it's props, or something

tony.kay23:02:02

agreed. That is possible with that support

tony.kay23:02:18

it also has dev/prod mode switching, so you can instrument just in dev