-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract methods to interfaces & change way of providing dependencies #25
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TextNotesRepo
interface should be renamed NotesRepo
and TextNotesRepoImpl
to just TextNotesRepo
. We will have other note type repos implement it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should migrate to Datastore
later
https://developer.android.com/topic/libraries/architecture/datastore
Got your point. However, let's keep one implementation for one interface as it is current approach. If in the future we add more, let's consider later. |
I just change the way to provide dependencies. If we need to migrate to data store, we should do it later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks
} | ||
|
||
private const val NOTE_EXT = "note" | ||
interface TextNotesRepo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface TextNotesRepo { | |
interface NotesRepo { |
import kotlin.io.path.name | ||
import kotlin.io.path.writeLines | ||
|
||
class TextNotesRepoImpl @Inject constructor(): TextNotesRepo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class TextNotesRepoImpl @Inject constructor(): TextNotesRepo { | |
class TextNotesRepo @Inject constructor(): NotesRepo { |
@Module | ||
abstract class RepositoryModule { | ||
@Binds | ||
abstract fun bindRepository(impl: TextNotesRepoImpl): TextNotesRepo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract fun bindRepository(impl: TextNotesRepoImpl): TextNotesRepo | |
abstract fun bindRepository(impl: TextNotesRepo): NotesRepo |
@@ -13,9 +13,11 @@ import space.taran.arkmemo.preferences.MemoPreferences | |||
import javax.inject.Inject | |||
|
|||
@HiltViewModel | |||
class NotesViewModel @Inject constructor(): ViewModel() { | |||
class NotesViewModel @Inject constructor( | |||
private val textNotesRepo: TextNotesRepo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private val textNotesRepo: TextNotesRepo, | |
private val textNotesRepo: NotesRepo, |
🚀 Summary
Extract methods to interfaces & change way of providing dependencies
Part 1 of #24
All new repository created must follow the principle
programming over abstraction instead of implementation
.They should be provided in
di
and as a module