Created
July 21, 2021 13:57
-
-
Save aasierra/1d34c3001b965b223802627b2feec46e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// Create view model that normally would be created in an injection system such as | |
// by viewModel, or Dagger, or Hilt. | |
// For our purposes of discussion we are just instantiating here as it does not matter | |
// where our BusinessLogicCenter (ViewModel) comes from. | |
val viewModel = ProductInfoBusinessLogicCenterViewModel() | |
setContent { | |
ProductInformation(viewModel.productInfo.observeAsState()) | |
} | |
} | |
} | |
@Composable | |
fun ProductInformation(displayObject: State<ProductInfoDisplay?>) { | |
displayObject.value?.let { | |
Column() { | |
Text( | |
text = it.productName | |
) | |
Text( | |
text = it.price | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment