Scoping with HILT (Dagger2)

  Рет қаралды 17,690

CodingWithMitch

CodingWithMitch

Күн бұрын

Пікірлер: 32
@silver10188
@silver10188 5 ай бұрын
I feel like they are hypocrites, they say don't use static, but this hilt thing is basically static fields that live somewhere.
@tejshah6225
@tejshah6225 2 жыл бұрын
@condingWithMitch, I have created my one helper class which inject It and i have 2 activity. both activity have a different have new object allocation. Means it create a new object every time. why?
@thesoftwareengineer_
@thesoftwareengineer_ 4 жыл бұрын
Thanks Mitch .... This is very helpful
@Tech-To-Logic
@Tech-To-Logic 4 жыл бұрын
Hi Mitch, tell me one thing. Suppose we have 2 activity. And I declared a component as an @ActivityComponent and inject on both activity. Now if I switched to one activity to another, then how destruction of that injected component will happen?
@codingwithmitch
@codingwithmitch 4 жыл бұрын
This is what I'm not clear on. a) Is there an ActivityComponent generated for every activity in the project? b) Or is there a single ActivityComponent that lives as long as there is at least one activity alive I'm leaning heavily towards "b". I don't think it makes sense if you consider scoping. So Probably: 1) ApplicationComponent lives as long as app is alive 2) ActivityRetainedComponent lives as long as there is at least one viewmodel alive 3) ActivityComponent lives as long as there is at least one activity alive 4) FragmentComponent.... etc... I couldn't find anywhere in the docs that explained this in detail.
@Zhuinden
@Zhuinden 4 жыл бұрын
@@codingwithmitch There is an ApplicationComponent that is global. There is an ActivityComponent configured globally, but instance created per each Activity. There is an ActivityRetainedComponent configured globally, but instance created per each Activity (that then places the component into a ViewModel and retrieves it from there if it already exists). There is a FragmentComponent that is configured globally, but instance created per each Activity. There is a hierarchy of Application -> ActivityRetained -> Activity -> Fragment.
@codingwithmitch
@codingwithmitch 4 жыл бұрын
@@Zhuinden So @FragmentScoped'd dependencies injected in "FragmentA" will live as long as ActivityA? And dependencies injected in "FragmentB" will live as long as ActivityB? Assuming FragmentA is a child of ActivityA and FragmentB is a child of ActivityB exclusively? BTW how you know this? Experimentation? Because I did not see this explained in the docs.
@Zhuinden
@Zhuinden 4 жыл бұрын
@@codingwithmitch A combination of Manuel Vivo's Twitter, the generated source code of CustomApplication_HiltComponents.FragmentC, and the source code of Hilt_MainActivity, ActivityComponentManager, and Hilt_SomeFragment and FragmentComponentManager. I haven't read all of the docs, it's kinda long :D
@Zhuinden
@Zhuinden 4 жыл бұрын
The tricky thing I don't really get yet is how custom EntryPoints work.
@Hackaprende
@Hackaprende 3 жыл бұрын
Thanks a lot! What happens if we use always Singleton Scope? Are we going to have performance issues?
@bhuvneshvarma7843
@bhuvneshvarma7843 3 жыл бұрын
@CodingWithMitch Thanks for such great tutorials..As per your tutorial "Activity Retain Scope gives same scope as View Model- more than activity but due before application die".I don't understand How you assumed that ViewModel lives more than Activity??Bcoz as per docs "ViewModel objects are scoped to the Lifecycle passed to the ViewModelProvider when getting the ViewModel. The ViewModel remains in memory until the Lifecycle it's scoped to goes away permanently: in the case of an activity, when it finishes, while in the case of a fragment, when it's detached."
@MohamedElnady001
@MohamedElnady001 4 жыл бұрын
الحب كله يالا Translation: thank you very much
@mohamadsh3874
@mohamadsh3874 3 жыл бұрын
بتغلط ليه يسطا
@RonnieOtieno
@RonnieOtieno 3 жыл бұрын
Dagger also throw runtime error, example is if you inject fragment and annotate it with Singleton. You will get an error that dagger doesn't support retained fragment instances or something like that
@matt-g-recovers
@matt-g-recovers 3 жыл бұрын
Ok, now I get it.
@gunjotsingh3638
@gunjotsingh3638 2 жыл бұрын
Loved it 🙌🏻
@PeteStMartin
@PeteStMartin 2 жыл бұрын
Engagement!
@yasserahmed3452
@yasserahmed3452 3 жыл бұрын
hi mitch, can you tell me if hilt is better or Kodein to use in di ? and thank you
@oscarperry641
@oscarperry641 4 жыл бұрын
pioneer
@codingwithmitch
@codingwithmitch 4 жыл бұрын
😘
@learnwithmicrostar
@learnwithmicrostar 3 жыл бұрын
Thank you BRO for the great tutorial !
@ChrisAthanas
@ChrisAthanas 3 жыл бұрын
Engage warp engines to 100k
@eddiej204
@eddiej204 3 жыл бұрын
By the Field injection approach, without define Scope, which component that the instance will be installed in?
@bhuvneshvarma7843
@bhuvneshvarma7843 3 жыл бұрын
By default all bindings of hilt are unscoped.That means that each time your app requests the binding Hilt creates a new instance of needed type
@sandeepemekar4014
@sandeepemekar4014 4 жыл бұрын
Thank you for the great Tutorial, Mitch!
@astrologykhan8125
@astrologykhan8125 4 жыл бұрын
What news say about hin??
@soumyaghosh5915
@soumyaghosh5915 3 жыл бұрын
Bro you are Awesome
@thai1711994
@thai1711994 4 жыл бұрын
Very helpful. Thank you
@amirs6472
@amirs6472 4 жыл бұрын
good
@jaserq
@jaserq 4 жыл бұрын
Perfect
HILT Constructor Injection Problems
8:02
CodingWithMitch
Рет қаралды 16 М.
Hilt Modules, Binds and Provides (Dagger2)
18:02
CodingWithMitch
Рет қаралды 22 М.
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 8 МЛН
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 57 МЛН
The selfish The Joker was taught a lesson by Officer Rabbit. #funny #supersiblings
00:12
MVVM  / MVI Repository Pattern with Hilt
1:00:24
CodingWithMitch
Рет қаралды 67 М.
Hilt - Android Dependency Injection
28:57
Android Developers
Рет қаралды 51 М.
iOS Development is Easier than Android Development (VLOG)
20:41
CodingWithMitch
Рет қаралды 52 М.
Hilt makes testing easier on Android
32:38
CodingWithMitch
Рет қаралды 16 М.
Fragment Constructor Injection with Hilt and Navigation Component
24:38
Learn Web Development And ACTUALLY Get A Job | Ultimate Guide
1:33:52
James Cross
Рет қаралды 1,4 МЛН
Hilt Dependency Injection (Kotlin Beginner Example)
21:20
CodingWithMitch
Рет қаралды 42 М.
Kotlin Coroutines 101 - Android Conference Talks
24:49
Android Developers
Рет қаралды 135 М.