om

Please ask the channel first, not @dnolen directly!
levitanong 2017-03-07T00:31:52.005163Z

@foobar component tree: Yes, afaik a component tree exists and it is a tree. unique ident: I don’t think it’s this simple, as there exists the possibility that more than one component is used to display information about the same logical entity. i.e. You can have two components with the same “ident”. updating state: What I’m used to and what I’m assuming the common case is, is for us to know in advance what the child components want. And if there could be many different classes of child components that have different needs, then we can expect them to be a bounded number of classes, and we would still be able to know in advance what the children want. So it seems you’re trying to do something vastly different from this, and I think it would help if you gave a concrete example of what you’re trying to do.

ag 2017-03-07T00:57:34.005164Z

can someone show me example of a component that “propagates” a custom event to the parent component?

ag 2017-03-07T01:02:08.005166Z

I I just pass a prop that a function and just call that function at some point from the body of the child component, is that ok?

raspasov 2017-03-07T01:15:52.005167Z

@ag didn’t quite understand, are you suggesting passing a function as a prop?

raspasov 2017-03-07T01:18:15.005168Z

and also, as always, why not simply transact! the global state? if you really need “event passing”, I would pass a channel from the parent to the child, and have the child put! messages onto the channel and have a (go (loop … ) ) in the parent that takes values from the channel and does something with them… but that can easily get messy and create a lot of dependency between components, so I would really think if you need it or if there’s a better way

matthavener 2017-03-07T01:23:19.005169Z

ag: yeah you can pass a function to a child, just do it thru a computed

2017-03-07T09:59:21.005171Z

I'm trying to remove some keys from a query before sending to the backend (ui namespaced). It isn't normalizing the response anymore with the default merge. What cue is om.next using to know that the response should be normalized? Is is comparing the query to the component with the ident and it can't normalize because I modified the query somehow?

alex-glv 2017-03-07T10:50:49.005172Z

@danielstockton it’s in the meta of the query, check if you still retain that

👍 1
2017-03-07T11:14:43.005173Z

Ah right @alex-glv, that's almost certainly it.

foobar 2017-03-07T16:12:53.005175Z

@levitanong Yes I know in advance what the components want. The information is transacted into the state. What I cannot update is the query for the component that hosts a newly added component. I obtain the html contents of a host component dynamically. I am then using prewalk to convert a html element into a component based on its attributes. An example would be an input element that specifies its data-source. My pre-walk would then instantiate an auto suggest component in place of the plain input element. What I cannot change (at least when using datascript as the state) is the host component query.

levitanong 2017-03-07T16:43:51.005176Z

@foobar Let me get this straight. You have some component, AutoSuggestComponent, which, as a user types, will call some method from, let’s say... google’s places autosuggest, which does some remote query and returns some premade markup containing the results. This markup is placed into app state as a string, which you parse and use in the render method of your AutoSuggestComponent. Is this correct?

foobar 2017-03-07T16:46:10.005177Z

Yes

foobar 2017-03-07T16:46:46.005178Z

Creating such a component is fine, creating it dynamically when required is not

foobar 2017-03-07T16:49:39.005179Z

The auto suggest component could be any kind of component, that was just an example.

levitanong 2017-03-07T16:49:42.005180Z

I’m not sure why you would need to update AutoSuggestComponent’s query though.

foobar 2017-03-07T16:50:13.005181Z

I don't I need to update the query of the component that is hosting the new auto-suggest component.

levitanong 2017-03-07T16:51:03.005182Z

so like, some component AppRoot

levitanong 2017-03-07T16:51:19.005183Z

and you have AutoSuggestComponent

levitanong 2017-03-07T16:51:36.005184Z

why would you need to update AppRoot’s query?

foobar 2017-03-07T16:52:33.005185Z

So AppRoot would get its contents from some dynamic source. I want to render some of the contents as components.

foobar 2017-03-07T16:53:41.005186Z

Therefore I need the query of AppRoot to change, obtain the required information, so it is available to be passed to the new components hosted by app root

levitanong 2017-03-07T16:53:52.005187Z

and i suppose dangerouslySetInnerHTML is unpalatable to you? lol

foobar 2017-03-07T16:55:47.005188Z

Well om next offers me all of the machinery to make a dynamic component just work, if only I could update the query of its host to fetch some additional information

levitanong 2017-03-07T17:02:05.005189Z

I’m curious, why would you use something that gave you markup though? Is there no alternative that just returns data?

foobar 2017-03-07T17:17:36.005190Z

Its more intuitive to describe a fragment of ui using markup. In this case an input element clearly communicates its purpose and is even functional by itself. The fact that I can add a couple of attributes and dynamically suggest values to the user is a nice to have.

foobar 2017-03-07T17:21:13.005191Z

My requirement is that my ui fragments are the bare minimum so I can create them by hand.

foobar 2017-03-07T17:22:25.005192Z

I want to create and render a new ui fragment, rather than re-compile my entire application.

sova-soars-the-sora 2017-03-07T17:34:14.005193Z

@foobar your needs are valid and i hear you on that. there may very well be a nice way to do this in om, but as far as i know it will be less effort on your part if you create an overarching UI piece that has all the other possible UI components included or mapped in. I have one gigantic (monadic?) component at the end of my UI code that basically gets each individual components' query and also maps the results to their UI code. I don't update any parent queries or anything like that, I just make one "super parent" at the end that says "i want this query and this one and this one" and, reiterating, it just maps to the extant ui components. i could share some example code if you like.

2017-03-07T18:24:51.005194Z

For om SSR, how can I get the initial state on the server? I can render to a string just fine now, and it gets rendered on the client. However the client has no state yet, so falls back to default values - and then updates again. I would like to pass the initial state to the client (maybe in a div), but how can I get it on the server?

peeja 2017-03-07T20:21:25.005195Z

In a read, is reading the (:query-root env) the correct way to detect whether you're reading an ident or a simple key?

anmonteiro 2017-03-07T20:38:32.005196Z

@peeja probably not

peeja 2017-03-07T20:38:52.005197Z

I don't see the ident anywhere else. Am I missing something?

anmonteiro 2017-03-07T20:38:54.005198Z

I would see if (-> env :ast :key) is an ident

peeja 2017-03-07T20:39:01.005199Z

Oh, in the ast

peeja 2017-03-07T20:39:23.005200Z

Fair enough. Is it typical to dig into the ast for that?

anmonteiro 2017-03-07T20:39:33.005201Z

IIRC, the ident will only be in query-root if you’re using path optimization

peeja 2017-03-07T20:39:53.005202Z

That makes sense

anmonteiro 2017-03-07T21:35:07.005205Z

@nha you may be looking for something like https://github.com/anmonteiro/om-next-fullstack/blob/master/src/shared/todomvc/todomvc.cljc#L75