Created
October 24, 2017 19:21
-
-
Save vRallev/d260052351a3b9d49a296a444bb8ae78 to your computer and use it in GitHub Desktop.
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
@Dao | |
interface NoteDao { | |
@Insert(onConflict = OnConflictStrategy.ABORT) | |
fun insert(note: Note): Long | |
@Update(onConflict = OnConflictStrategy.ABORT) | |
fun update(note: Note): Int | |
@Query("SELECT * FROM notes") | |
fun observeAllNotes(): Flowable<Note> | |
@Query("SELECT * FROM notes WHERE id = :id") | |
fun findById(id: Long): Note | |
} | |
class NoteDaoHelper internal constructor(private val noteDao: NoteDao) : NoteDao by noteDao { | |
fun updateAndReturnNewValue(note: Note): Note { | |
update(note) | |
return findById(note.id) | |
} | |
override fun observeAllNotes(): Flowable<Note> { | |
return noteDao.observeAllNotes().subscribeOn(Schedulers.io()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment