untangled

NEW CHANNEL: #fulcro
urbank 2017-02-27T00:01:21.004597Z

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

urbank 2017-02-27T00:02:37.004598Z

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

urbank 2017-02-27T00:02:56.004599Z

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

urbank 2017-02-27T00:04:40.004600Z

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

urbank 2017-02-27T00:05:02.004601Z

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

qqq 2017-02-27T03:44:55.004604Z

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?

cjmurphy 2017-02-27T04:09:10.004605Z

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

qqq 2017-02-27T04:09:39.004606Z

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

qqq 2017-02-27T04:09:56.004608Z

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

cjmurphy 2017-02-27T04:10:32.004609Z

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

qqq 2017-02-27T04:10:52.004610Z

so I'm simulating a basic desktop with windows

qqq 2017-02-27T04:11:02.004611Z

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

cjmurphy 2017-02-27T04:11:48.004612Z

Definitely in app state then.

qqq 2017-02-27T10:33:23.004613Z

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?

qqq 2017-02-27T10:34:08.004614Z

I guess https://github.com/omcljs/om/wiki/Documentation-(om.next)#factory validator

cjmurphy 2017-02-27T11:52:52.004616Z

cjmurphy 2017-02-27T11:54:04.004617Z

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

qqq 2017-02-27T11:54:26.004618Z

what? that has to do with ui

qqq 2017-02-27T11:54:40.004619Z

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

2017-02-27T13:16:15.004620Z

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?

2017-02-27T15:36:07.004621Z

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.kay 2017-02-27T16:11:19.004622Z

@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.kay 2017-02-27T16:12:34.004623Z

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

tony.kay 2017-02-27T16:16:37.004624Z

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

urbank 2017-02-27T16:20:10.004625Z

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

tony.kay 2017-02-27T16:20:33.004626Z

If you've watched them, then clarify your question

tony.kay 2017-02-27T16:20:42.004627Z

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

tony.kay 2017-02-27T16:21:08.004628Z

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

tony.kay 2017-02-27T16:21:20.004629Z

but strip it down to bare minimum

tony.kay 2017-02-27T16:21:50.004630Z

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

urbank 2017-02-27T16:23:08.004632Z

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

urbank 2017-02-27T16:26:29.004633Z

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.kay 2017-02-27T16:28:17.004635Z

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.kay 2017-02-27T16:28:44.004636Z

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.kay 2017-02-27T16:29:05.004637Z

at least in terms of "decoupled from UI".

tony.kay 2017-02-27T16:30:06.004638Z

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.kay 2017-02-27T16:30:14.004639Z

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

tony.kay 2017-02-27T16:30:48.004640Z

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

tony.kay 2017-02-27T16:31:06.004641Z

only inside of mutations and incoming data normalization

tony.kay 2017-02-27T16:31:32.004642Z

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

tony.kay 2017-02-27T16:33:34.004643Z

(and an example is still ok 😉 )

urbank 2017-02-27T16:34:19.004644Z

Yeah, still making one 🙂

urbank 2017-02-27T17:03:15.004646Z

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

urbank 2017-02-27T17:06:02.004647Z

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

urbank 2017-02-27T17:06:54.004648Z

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

urbank 2017-02-27T17:08:01.004649Z

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)

urbank 2017-02-27T17:08:29.004650Z

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

urbank 2017-02-27T17:10:05.004651Z

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

urbank 2017-02-27T17:11:18.004652Z

So that's even better

urbank 2017-02-27T17:15:27.004655Z

So I suppose something about queries confused me.

urbank 2017-02-27T17:18:13.004657Z

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

urbank 2017-02-27T17:18:20.004658Z

oh wait it does, doesn't it

urbank 2017-02-27T17:18:44.004659Z

it just has 'cardinality many' ?

urbank 2017-02-27T17:18:51.004660Z

if so, it's all clear 🙂

sova-soars-the-sora 2017-02-27T18:17:15.004661Z

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

tony.kay 2017-02-27T18:22:15.004662Z

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

tony.kay 2017-02-27T18:22:33.004664Z

: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.kay 2017-02-27T18:23:18.004666Z

nothing really more to it 🙂

tony.kay 2017-02-27T18:23:32.004667Z

that covers like 90% of what you need to know

urbank 2017-02-27T18:27:44.004668Z

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

tony.kay 2017-02-27T18:27:54.004669Z

no problem

2017-02-27T23:19:56.004670Z

what's the status of defuitools?

2017-02-27T23:20:08.004671Z

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

2017-02-27T23:20:13.004672Z

any docs

tony.kay 2017-02-27T23:20:51.004673Z

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

tony.kay 2017-02-27T23:20:57.004674Z

There are some examples in the source itself

tony.kay 2017-02-27T23:21:05.004675Z

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

2017-02-27T23:21:40.004676Z

kk, thanks

2017-02-27T23:21:42.004677Z

reading the source

2017-02-27T23:23:49.004678Z

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

tony.kay 2017-02-27T23:24:02.004679Z

agreed. That is possible with that support

tony.kay 2017-02-27T23:24:18.004680Z

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