nate
08/28/2018, 3:49 PMclass ProjectHomeViewModel: ViewModel() {
private var projectUseCase = GetProjectsUseCase(Injector.projectDao)
val items = FXCollections.observableArrayList<ProjectCard>()!!
init {
getProjects()
}
private fun getProjects() {
projectUseCase.getProjects().subscribe {
items.setAll(
it.map{
ProjectCard(it).apply{
loadProjectButton.action{
}
}
}
)
}
}
}
my projectUseCase.getProjects() returns an Observable<List> which I subscribe to and map into the observableArrayList = items. I then use this items list inside my datagrid. basically, my question is, is it philosophically correct to have my ProjectCard's action present here in the viewModel? It works but i'm not sure if it's good/right...