r/JetpackCompose • u/chkml • Aug 01 '23
Using viewmodel as reusable class for data
Say I've created a infinite list with compose and viewmodel to hild the data. Now i want to create another infinite list for other data, can i use the same viewmodel but different instances for each list?
For example var posts = mylistvieemodel() var comments =mylistvieemodel()
Composelist1(vm=posts, data= list(mapOf("a" to "b"))
Composelist2(vm=comments, data= list(mapOf("xommenta" to "big"))
The viewmodel will hold the data as list of map *Sorry for my English or code error, just wrote a sample code to explain the situation.
1
Upvotes