This repository has been archived by the owner on May 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repository and ViewModel implementation for all notes screen. Issue #16
- Loading branch information
1 parent
d9c1f45
commit 935db3c
Showing
4 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
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
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
14 changes: 13 additions & 1 deletion
14
app/src/main/java/com/hadiyarajesh/notex/repository/NotesRepository.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
package com.hadiyarajesh.notex.repository | ||
|
||
import com.hadiyarajesh.notex.database.dao.NoteDao | ||
import com.hadiyarajesh.notex.database.entity.Note | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class NotesRepository @Inject constructor() { | ||
class NotesRepository @Inject constructor(private val noteDao: NoteDao) { | ||
|
||
|
||
suspend fun add(note: Note): Long = noteDao.insertOrUpdate(note) | ||
|
||
suspend fun update(note: Note): Long = noteDao.insertOrUpdate(note) | ||
|
||
suspend fun remove(note: Note): Note = noteDao.deleteNote(note) | ||
|
||
suspend fun allNotes(): Flow<List<Note>> = noteDao.getNotes() | ||
} |
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