Created
July 21, 2021 13:12
-
-
Save aasierra/56ef21ab430983bdb9eadb27a8ecee21 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
import kotlinx.android.synthetic.main.activity_main.* | |
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
// 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() | |
viewModel.productInfo.observe(this, { displayObject -> | |
// Using kotlin synthetics we simply set the text. | |
productName.text = displayObject.productName | |
price.text = displayObject.price | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment