Skip to content

Instantly share code, notes, and snippets.

@markchristopherng
Last active November 19, 2019 05:54
Show Gist options
  • Save markchristopherng/4cca948e574a2290a1a5a8cf6fdbe00d to your computer and use it in GitHub Desktop.
Save markchristopherng/4cca948e574a2290a1a5a8cf6fdbe00d to your computer and use it in GitHub Desktop.
class PayBillViewModel : AuspostViewModel() {
@Inject
lateinit var payBillManager: PayBillManager
@Inject
lateinit var save: StateLiveData<Unit>
@Inject
lateinit var delete: StateLiveData<Unit>
@Inject
lateinit var bills: StateLiveData<List<SavedBill>>
fun save(bill: SavedBill?) {
save.executeWith(viewModelScope) {
payBillManager.save(bill)
}
}
fun delete(id: Int?) {
save.executeWith(viewModelScope) {
payBillManager.delete(id)
}
}
fun getAll() {
bills.loadWith(viewModelScope) {
payBillManager.getAll()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment