carlw
08/28/2018, 3:06 PMmikehearn
08/28/2018, 3:08 PMnate
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...nate
08/28/2018, 3:49 PMbj0
08/28/2018, 4:00 PMcarlw
08/28/2018, 4:02 PMbj0
08/28/2018, 4:04 PMStylesheet
?carlw
08/28/2018, 4:04 PMbj0
08/28/2018, 4:04 PMtoggleClass
and a propertycarlw
08/28/2018, 4:05 PMcarlw
08/28/2018, 4:06 PMbj0
08/28/2018, 4:07 PMlabel and class
, not sure how to make it more specificcarlw
08/28/2018, 4:07 PMbj0
08/28/2018, 4:07 PMcarlw
08/28/2018, 4:07 PMbj0
08/28/2018, 4:08 PMcarlw
08/28/2018, 4:10 PMbj0
08/28/2018, 4:12 PMlabel and green {
backgroundColor += Color.GREEN
}
label and red {
textFill = Color.WHITE
backgroundColor += Color.RED
}
if green
is bound to a 'connected' property, and red
is bound to an error property, I would want red
to override green
carlw
08/28/2018, 4:14 PMcarlw
08/28/2018, 4:14 PMbj0
08/28/2018, 4:16 PMtoggleClass
bj0
08/28/2018, 4:19 PM!important
flag, is that not implemented?carlw
08/28/2018, 4:19 PMcarlw
08/28/2018, 4:22 PMbj0
08/28/2018, 4:26 PMtoggleClass
will not work for that, and I haven't been able to get bindClass
to workcarlw
08/28/2018, 5:02 PMcarlw
08/28/2018, 5:02 PMbj0
08/28/2018, 5:05 PMbindClass
which I thought does it for you. Something like this:
val binding = nonNullObjectBinding(vm.statusProperty) {
<http://logger.info|logger.info> { "binding change ,$value" }
when (value) {
is ProxyStatus.Error -> Styles.error
ProxyStatus.Started -> Styles.active
else -> Stylesheet.label
}
}
bindClass(binding)
bj0
08/28/2018, 5:06 PMonChange
listener is never firing thoughcarlw
08/28/2018, 5:07 PM