7
u/FascistBodybuilder Jan 03 '19
I never used Dagger because I couldnt figure it out. It's some sort of coffee maker/thermosiphon thing.
3
u/bernaferrari Jan 03 '19
I'm using it as Zhuinden wrote here, one of the best tutorials available: https://medium.com/@Zhuinden/that-missing-guide-how-to-use-dagger2-ef116fbea97
You don't need to make overly complicated things. I'm using it basically as a global singleton most of the time. I can fetch what I want any time, globally, and all just works. Other people take care of subscoping and etc, but you are free to do the way you feel comfortable. It took me today about 3 hours to "redesign" an app (24 files changed and Dagger introduced), it wasn't hard. After a few trial and errors you get good at it.
4
u/FascistBodybuilder Jan 03 '19
Lol thanks
TBH I was just making a joke about the stupidly convoluted introduction that dagger uses tho
1
1
Jan 02 '19
Had a little fun while troubleshooting a problem when I was trying to implement a bottom app bar.
31
u/Zhuinden Jan 02 '19
But what exactly does Dagger have to do with a BottomAppBar? :o
20
u/eMperror_ Jan 02 '19
Nothing
7
Jan 02 '19
True. The project we were brought on to was already built with dagger as a backbone so it was basically the client having two requirements that would not work together.
1
Jan 02 '19
The project we were working on included dagger already but wanted to move to the bottom app bar presented at IO but this required AndroidX migration. Big oof
6
u/renges Jan 02 '19
Isn't turning on jetifier solve this issue?
2
Jan 02 '19
Yeah for us it did! But I know we had to make some other gradle changes to have it work. I know others are not so lucky though.
1
u/bernaferrari Jan 03 '19
You could have the bottom bar with material components v28. There is no change to AndroidX.
1
u/zsmb Kotlin Advocate Jan 02 '19
Well, just that it would need to play nice with AndroidX for that component to be available (although I think you can still find a non-androidx release with it too).
2
u/Zhuinden Jan 02 '19
AFAIK you do need to update dagger to 2.20 but then it'll work fine
0
Jan 02 '19
[deleted]
3
u/Zhuinden Jan 02 '19
Androidx however has better support with 2.20.
There was some guy called ursus who had a question for me and it was very interesting, allowing better androidx allows using AndroidInjection for Conductor controllers and Views. So it's actually much cleaner internally.
5
u/100k45h Jan 02 '19
Does that mean that your activities extend DaggerAppCompatActivity? Because I'd avoid that. You can still use AndroidInjection in a regular Activity. No need to extend DaggerAppCompatActivity.
That said, cannot resolve DaggerAppCompatActivity sounds a lot like you're just missing some dependency in your module's gradle file.
2
u/Pzychotix Jan 02 '19
You'd need it if you had subcomponents at the fragment level that depended on your activity scoped component. Either that or simply reimplementing what Dagger*Activity does.
1
u/100k45h Jan 03 '19
Right, well, ever since I've started using
dagger-androidI don't really use components... When usingdagger-android, I'm just happy with one app level component... So I didn't face this issue so far.
13
4
4
u/To6y Staff engineer Jan 03 '19
These were my thoughts with data binding and LiveData last year in 2017.
Hey guys, here's a new observable thing! It's better than the thing we gave you last year! You'll have to keep using the old thing for a lot of stuff until we update AGP though...
2
u/chrisji Jan 02 '19
Go for Koin. It made my life as a developer so much easier. https://github.com/InsertKoinIO/koin
1
u/L0neKitsune Jan 02 '19
Koin is so much nicer than dagger. I wish my main client would switch, I already use it on all my other projects.
5
-5
u/pavi2410 Fuchsia Dev Jan 02 '19
What is Dagger? 🤔
8
u/Zhuinden Jan 02 '19
It's a sharp object you use for injecting your constructors with dependencies and thus replace dependencies with associations that can be configured from the outside, and Dagger auto-resolves your object graph and creates what's necessary to bind your objects together.
So you can build singletons without the singleton pattern (so that it stays configurable from the outside while still ensuring expected scoping behavior)
38
u/[deleted] Jan 02 '19
I've never enjoyed reading / debugging the use of the dagger android components. While the Android framework is awkward to use with dependency injection, I don't think Dagger 2's solution is the right one. I much prefer handling the injection of components / modules myself with the use of targets