Just trying to see if my interpretation of Molecul...
# squarelibraries
c
Just trying to see if my interpretation of Molecules example scenario is correct. So the doc says
Copy code
val userFlow = db.userObservable()
val balanceFlow = db.balanceObservable()

@Composable
fun Profile() {
  val user by userFlow.subscribeAsState(null)
  val balance by balanceFlow.subscribeAsState(0L)

  if (user == null) {
    Text("Loading…")
  } else {
    Text("${user.name} - $balance")
  }
}
Unfortunately, we are mixing business logic with display logic which makes testing harder than if it were separated. The display layer is also interacting directly with the storage layer which creates undesirable coupling. Additionally, if we want to power a different display with the same logic (potentially on another platform) we cannot.
Extracting the business logic to a presenter-like object fixes these three things.
so the three things wrong with this are 1. "mixing business logic with display logic" | Is that referring to
Text("${user.name} - $balance")
? 2. "The display layer is also interacting directly with the storage layer which creates undesirable coupling" | That's reffering to
val userFlow = db.userObservable()
right? 3. "if we want to power a different display with the same logic (potentially on another platform) we cannot." | I don't get that. If we were using compose for desktop, the above would work?