Fork me on GitHub
#om-next
<
2016-06-01
>
danburton17:06:21

I'm having a hard time understanding when to use params and when to use props. Particularly: I've got a "details view" component which displays the details for (basically) a row in a database. Should this component have a param for the ID of the row it is displaying, and I use set-query to update the param whenever I want to display a different row? Or should the parent component take responsibility for managing which ID to query for, and merely instantiate the details view with the props after the query comes back with data?

danburton18:06:07

Related. It seems like any functionality provided by IQueryParams can instead be accomplished by props.

(query [this] (let [pseudo-param (if (om/component? this) (-> this om/props :pseudo-param) "default value")] ...))

danburton18:06:14

So I'm unclear on whether I should be updating the state atom in order to trigger the appropriate query updates, or whether I should be updating the query params in order to trigger the appropriate query updates.

vinnyataide19:06:09

query param seems like the most appropriate answer

vinnyataide19:06:03

basically the queries are managed in a parent component in the background, that's how relay works, the params are just the props from the wrapper component that sends the state to the child details view, using state and props just duplicates the idea

vinnyataide19:06:53

what happens behind the query update is a update in the wrapper components state that triggers the request

danburton22:06:38

Trying to decide now on whether to represent a query as [([:foo/by-id id] {:limit 10 :etc :etc})] or as [(:foo/detail {:id id :limit 10 :etc :etc})]

danburton22:06:32

I'm not really sure which is a more "canonical" query for the server to interpret.