Skip to content
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

강원대_Android_이아림_5주차과제_STEP2 #70

Open
wants to merge 13 commits into
base: arieum
Choose a base branch
from

Conversation

arieum
Copy link

@arieum arieum commented Jul 26, 2024

저번주에 헤맸던 ⚠️스페이스바이슈⚠️에 대해 코루틴을 적용했습니다!

@mkSpace
Copy link

mkSpace commented Jul 28, 2024

리베이스 한 번 해주세요~

Copy link

@mkSpace mkSpace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이번주차도 수고하셨습니다!

HIlt를 매우 잘 적용하셨습니다. Coroutine으로도 변경을 잘 하셨구요.

하지만 조금 더 레벨업을 원하신다면 Flow를 잘 이용해보세요.

사용자의 입력이 View -> ViewModel -> Repository 를 통해 Remote Call을 하고 Remote Call에서 내려받은 데이터를 Repository (Remote Call) -> Room -> ViewModel -> View 로 흐르는 스트림을 작성해보시면 좋을 것 같네요!

다음주차도 화이팅입니다!

Comment on lines +15 to +26
object DatabaseModule {
@Provides
@Singleton
fun provideDatabase(@ApplicationContext context: Context): AppDatabase {
return AppDatabase.getDatabase(context)
}

@Provides
fun providePlaceDao(database: AppDatabase): PlaceDao {
return database.placeDao()
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

역할에 맞게 Module을 잘 구현하셨습니다! 👍
Hilt에 익숙해지시면 확실히 의존성 관리에 편하실거에요

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

꺅>.<😆

Comment on lines +18 to +20
fun provideSharedPreferences(@ApplicationContext context: Context): SharedPreferences {
return context.getSharedPreferences("LastLocation", Context.MODE_PRIVATE)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 방법도 좋은데 SharedPreferences를 관리하는 객체를 따로 만들어도 좋을 것 같습니다. 예를들어
KakaoMapSharedPreferences & KakaoMapSharedPreferencesImpl
등으로 Interface와 구현체를 분리해서 Module을 통해 의존성 주입해주심 더 깔끔할 것 같습니다.
해당 객체에는 Location 직렬화 및 역직렬화 하는 로직을 구현해서 사용하심 좋을 것 같습니다.

Comment on lines 27 to 29
fun provideContext(application: Application): Context {
return application.applicationContext
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hilt는 EntryPoint 등록을 통해서 각 Scope에 맞는 Context를 제공합니다.
@ApplicationContext를 활용해보세요

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fun provideContext(@ApplicationContext context: Context): Context { return context }

@@ -9,9 +9,10 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import javax.inject.Inject

class LogRepository @Inject constructor (private val application: MyApplication, private val placeDao: PlaceDao): LogRepositoryInterface {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Inject 를 사용해서 의존성을 생성하셨네요. 하지만, RepositoryModule에서도 LogRepository 의존성을 생성해주고 있는데 하나로 통일하시면 좋을 것 같네요.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 이해가 가지않습니다...! LogRepository는 MyApplication과 PlaceDao에 대해서 의존성 주입을 받고있고 RepositoryModule에서 provideLogRepository를 작성한 이유는 LogViewModel에 의존성을 주입하기 위함이었습니다! 어떤 걸 통일해야하는지 이해가 가지 않습니다...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module을 통한 주입과 @Inject constructor를 이용한 주입 두 가지를 사용할 필요는 없다는 말씀입니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants