Fork me on GitHub
#om
<
2017-03-07
>
levitanong00:03:52

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

ag00:03:34

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

ag01:03:08

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?

raspasov01:03:52

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

raspasov01:03:15

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

matthavener01:03:19

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

danielstockton09:03:21

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-glv10:03:49

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

danielstockton11:03:43

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

foobar16:03:53

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

levitanong16:03:51

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

foobar16:03:46

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

foobar16:03:39

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

levitanong16:03:42

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

foobar16:03:13

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

levitanong16:03:03

so like, some component AppRoot

levitanong16:03:19

and you have AutoSuggestComponent

levitanong16:03:36

why would you need to update AppRoot’s query?

foobar16:03:33

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

foobar16:03:41

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

levitanong16:03:52

and i suppose dangerouslySetInnerHTML is unpalatable to you? lol

foobar16:03:47

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

levitanong17:03:05

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

foobar17:03:36

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.

foobar17:03:13

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

foobar17:03:25

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

sova-soars-the-sora17:03:14

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

nha18:03:51

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?

peeja20:03:25

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

peeja20:03:52

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

anmonteiro20:03:54

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

peeja20:03:01

Oh, in the ast

peeja20:03:23

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

anmonteiro20:03:33

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

peeja20:03:53

That makes sense