Fork me on GitHub

I want to mutate the database (with urls) through an event handler, and then due to the change in the urls trigger server calls to load data for related components... subscribing to the database for the url changes seems to be the correct way to trigger the call. But where do I put the subscribe? in let block that hangs outside of any function as code executed in a namespace?


by "with urls" I mean that the data values I'm adding are urls, which represent a source of data for a component. (Think results tables in a dashboard)


I currently load the cell definitions into the database, there's a lot of useful information, and each cell is uniquely named, the layout is in a 2d array and I render based on the keyword identifier in each cell. However, there are more definitions than there are cells on the page. So, I don't load every single component. I want to only fire the ones that are in the dashboard cells. I don't want to "cross streams" but it makes sense that if the cell changes in the database, I should not only re-render, I should kick off the event stream that will fetch and eventually render the data. The render of the table would handle the subscription for the table-data when the result shows up. But there's no clear place in the sequence to subscribe to the url/pageNumber change in the db and fire the [:table-data-load-event <url> :<component-id> <pageNumber>] event handler.


Do I dispatch then event in the component definition when it is first rendered? Next/Previous buttons will handle the rest of the data loading...


Are you asking this: 1. You have views/components which need data (from a server database) 2. But some of this data isn't loaded from the server yet 3. Subject to the needs of subscriptions in those views/components you are wondering how/when to trigger the load of this data (from the server)?


In effect, do you want a subscribe which delivers data from the server database (almost bypassing app-db)?