-
Notifications
You must be signed in to change notification settings - Fork 1
LoginActivity 제거 및 MainActivity로 진입점 통일 #23
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
LoginActivity 제거 및 MainActivity로 진입점 통일 #23
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
chanho0908
left a comment
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.
현수 고생했어 ! 궁금한거랑 몇 가지 수정할거 남겨봤어 :)
| import org.koin.android.ext.koin.androidContext | ||
| import org.koin.core.context.startKoin |
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.
요긴 사용되고있지 않는 것 같아! 👀
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.
네 import 지웠습니다!
| import org.koin.core.module.Module | ||
|
|
||
| fun initKoin( | ||
| context: Context? = null, |
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.
Context가 nullable 이유가 혹시 있을까 ?
지금은 TwixApplication에서만 호출되서 nullable이지 않아도 괜찮을 것 같은데 어떤 확장성을 고려한걸까 ?
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.
CMP로 데스크탑까지 확장하게 되면 Jvm 환경에서는 context가 없어서 일단 nullable로 뒀습니다!
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.
오호 대박 그건 몰랐네 👍
| import org.koin.dsl.module | ||
|
|
||
| val loginModule = module { | ||
| single<NavGraphContributor>(named("LoginNavGraph")) { LoginNavGraph } |
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.
혹시 하드코딩된 qualifier를 사용한 이유가 있을까 ?
내가 이해하기엔 class로 각각의 Feature들의 NavGraph를 고유하게 만들어서
qualifier가 필요하지 않을까란 생각이 들어서 ! 🙂
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.
koin이 기본적으로 타입을 키로 활용해서 의존성을 관리합니다. 저희는 feature 모듈마다 NavGraphContributor를 만들어 등록하는 구조라 같은 타입이 여러 개 생길 수밖에 없는데, qualifier가 없으면 koin 입장에서는 서로 다른 그래프를 구분할 수 없습니다.
single<NavGraphContributor> { LoginNavGraph }
single<NavGraphContributor> { HomeNavGraph }
예를 들어 이렇게 두개를 등록하면 등록 단계에서 키가 충돌하고 결과적으로 컨테이너에 등록된 Graph는 하나만 남게 돼요. named는 같은 타입의 NavGraph들을 구분하기 위한 용도로 활용합니다.
하드코딩된 값들은 Graph마다 route가 있으니 이걸 활용해서 개선하면 될 거 같아요!
| import com.twix.navigation.NavRoutes | ||
| import com.twix.navigation.base.NavGraphContributor | ||
|
|
||
| object LoginNavGraph: NavGraphContributor { |
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.
요건 단순히 궁금증인데 object로 선언한 이유가 궁금해 ! 😃
내가 생각하기에 어차피 Koin에 Singleton으로 등록하기 때문에
일반 class든 object든 크게 상관 없을거라고 생각하긴 하는데 현수의 생각도 궁금해서 !
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.
지금 NavGraph는 내부 상태 없이 순수하게 정해진 그래프만 등록하는 역할이에요. 그래서 여러 인스턴스를 만들 필요도 없고 여러 인스턴스를 생성하는 게 가능할 필요도 없다고 생각해요.
class로 구현하는 게 불가능한 건 아니지만 class로 구현하면 모듈에 등록하는 과정에서 누군가는 인스턴스 생성을 책임져야 해요. 그리고 이론상 여러곳에서 인스턴스를 생성하는 게 가능해지기 때문에 종합적으로 고려했을 때 class보다는 object로 구현하는 게 맞다고 판단했습니다!
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.
그렇구나 그런 이유라면 너무 좋은 것 같아 ! 😄
dogmania
left a comment
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.
import 제거했고 qualifier NavRoute로 수정했습니다!
| import org.koin.android.ext.koin.androidContext | ||
| import org.koin.core.context.startKoin |
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.
네 import 지웠습니다!
| import org.koin.core.module.Module | ||
|
|
||
| fun initKoin( | ||
| context: Context? = null, |
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.
CMP로 데스크탑까지 확장하게 되면 Jvm 환경에서는 context가 없어서 일단 nullable로 뒀습니다!
| import org.koin.dsl.module | ||
|
|
||
| val loginModule = module { | ||
| single<NavGraphContributor>(named("LoginNavGraph")) { LoginNavGraph } |
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.
koin이 기본적으로 타입을 키로 활용해서 의존성을 관리합니다. 저희는 feature 모듈마다 NavGraphContributor를 만들어 등록하는 구조라 같은 타입이 여러 개 생길 수밖에 없는데, qualifier가 없으면 koin 입장에서는 서로 다른 그래프를 구분할 수 없습니다.
single<NavGraphContributor> { LoginNavGraph }
single<NavGraphContributor> { HomeNavGraph }
예를 들어 이렇게 두개를 등록하면 등록 단계에서 키가 충돌하고 결과적으로 컨테이너에 등록된 Graph는 하나만 남게 돼요. named는 같은 타입의 NavGraph들을 구분하기 위한 용도로 활용합니다.
하드코딩된 값들은 Graph마다 route가 있으니 이걸 활용해서 개선하면 될 거 같아요!
| import com.twix.navigation.NavRoutes | ||
| import com.twix.navigation.base.NavGraphContributor | ||
|
|
||
| object LoginNavGraph: NavGraphContributor { |
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.
지금 NavGraph는 내부 상태 없이 순수하게 정해진 그래프만 등록하는 역할이에요. 그래서 여러 인스턴스를 만들 필요도 없고 여러 인스턴스를 생성하는 게 가능할 필요도 없다고 생각해요.
class로 구현하는 게 불가능한 건 아니지만 class로 구현하면 모듈에 등록하는 과정에서 누군가는 인스턴스 생성을 책임져야 해요. 그리고 이론상 여러곳에서 인스턴스를 생성하는 게 가능해지기 때문에 종합적으로 고려했을 때 class보다는 object로 구현하는 게 맞다고 판단했습니다!
chanho0908
left a comment
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.
고생했어 현수야 ! 🏊 🏊 🏊
| import org.koin.core.module.Module | ||
|
|
||
| fun initKoin( | ||
| context: Context? = null, |
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.
오호 대박 그건 몰랐네 👍
| import com.twix.navigation.NavRoutes | ||
| import com.twix.navigation.base.NavGraphContributor | ||
|
|
||
| object LoginNavGraph: NavGraphContributor { |
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.
그렇구나 그런 이유라면 너무 좋은 것 같아 ! 😄
이슈 번호
작업내용
리뷰어에게 추가로 요구하는 사항 (선택)
멀티 모듈에서 koin을 활용하는 방법을 이 pr에서 최대한 구현해 봤습니다. 추후에 구현하시는 feature 모듈마다 NavGraphContributor 구현체를 만들고 di 패키지에서 koin 모듈을 만들면 됩니다. 다음으로는 이 koin 모듈을 :app에 존재하는 FeatureModules에 추가해주세요.
현재 :feature:login에 뷰모델이 없기 때문에 뷰모델 관련된 di 코드가 추가되지 않은 상태인데, NavGraphContributor를 koin 모듈에 등록하듯이 LoginViewModel을 koin 모듈에 추가해주시면 됩니다.
뷰모델 Koin 등록은 위와 같이 해주시면 됩니다.