I've go this code: ```@Composable fun RssSeriesCo...
# compose
r
I've go this code:
Copy code
@Composable
fun RssSeriesCompose(url: HttpUrl, dao: RssFeedDao, client: HttpHandler) {
    val TAG = "RssSeriesActivity"
    Log.d(TAG, "Recomposing")
    val videosAndPosition by produceState(VideosAndPosition(listOf(), null), url) {
        Log.d(TAG, "Fetching state")
        val initialVideos = dao.getNewestVideosFirst(url)
        val initialPosition = dao.getPosition(url)
        value = VideosAndPosition(initialVideos, initialPosition)
        val feedData = getNewestFeed(url, client)
        Log.d(TAG, "Feed data: $feedData")
        dao.insertAll(*feedData.toTypedArray())
        val videos = dao.getNewestVideosFirst(url)
        val position = dao.getPosition(url)
        value = VideosAndPosition(videos, position)
    }

    AutoPlayPlaylist(videosAndPosition, dao = dao)
}
With the idea that I initially use the cached feed, then update accordingly. However, during the test I'm changing
client
, but it doesn't rerun
getNewestFeed()
. Can I poke compose here?
f
all this business logic should not be in a composable, but in a viewmodel or presenter instead, so that the composable is only responsible for rendering the UI. However, if you want your
produceState
to restart when you change
client
, make
client
one of the `key`s on the
produceState
call (edit: typos)
☝️ 1
r
Aye, I don't think I want the
viewModel
logic, refreshing the data on invoking the activity is fine, but I'll extract the whole logic out of
@Composable
, thanks.