Created
July 9, 2019 12:30
-
-
Save adityawibisana/6056590a5e217a3d2a8372d6efd53a59 to your computer and use it in GitHub Desktop.
simple custom function to run on UI and background respectively
This file contains 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
//run this on default background thread | |
runOnDefaultThread({ | |
firstNote = NoteRepository.getOrCreateFirstNote(applicationContext) | |
firstNoteLive = NoteRepository.getLiveDataNoteById(applicationContext, firstNote.id) | |
//run on main thread | |
runOnUiThread { | |
firstNoteLive.observe(this, Observer<Note> { | |
Log.v(TAG, "First note is changed, value: ${it.content}") | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment