Every time I hear your intro, I automatically give the video thumbs up. 😂
@TheAndroidFactory7 ай бұрын
Hahaha I have said it so many times now it is just a staple of the content at this point. I appreciate your support 🙌
@god_bikaАй бұрын
Doesnt multimodule suppose you to have to add another @module-ed file at least? Or am i getting something wrong?
@TheAndroidFactoryАй бұрын
Sorry, this is specifically talking about modules for the project, not just module-annotated files as it relates to Hilt. So for this project we have an 'app' module (the standard one) and also a 'network' module (that has a bunch of our network related code). These modules are a bit different than the files annotated @Module
@nicoqueijo5 ай бұрын
6:01 how did you highlight an instance of VERSION_11 and quickly highlighted the other two for quick editing?
@TheAndroidFactory5 ай бұрын
I think it is Alt + j on Windows and CTRL + g on Mac! Super useful shortcut once you get the hang of it. Copy and paste over multiple cursors works too which is satisfying 😎
@nicoqueijo5 ай бұрын
How come the hilt NetworkModule doesn't reside in the network module? For di, are all the hilt modules supposed to reside in the app module?
@TheAndroidFactory5 ай бұрын
Hey this is a great question, but no we want this DI module in the app module because we are using Hilt in the app to inject our networking "library" into the main module. If you had dependencies you needed to organize in the network module to make that function properly, you could use Hilt again in that module to map your dependencies. Does that make sense?
@nicoqueijo5 ай бұрын
@@TheAndroidFactory I think so. So if I have a Repository in a data module that uses a KtorClient (that resides in the network module) I would make the NetworkModule (that provides the KtorClient) inside the data module, correct?
@TheAndroidFactory5 ай бұрын
Yes, correct. You use the Hilt modules inside your modules that contain the code to either (1) map dependencies your module needs internally for itself to work or (2) fetch dependencies from "outside" your module that your code depends on to operate.
@nicoqueijo5 ай бұрын
@@TheAndroidFactory Thank you so much for the explanations!
@TheAndroidFactory5 ай бұрын
Of course! Hope it helps :)
@shaharts83339 ай бұрын
Thanks for sharing
@TheAndroidFactory9 ай бұрын
Thanks for following!
@GCkk4 ай бұрын
Hi, Is their a way to inject the applicationContext into multi-module lib?
@TheAndroidFactory4 ай бұрын
For sure! Checkout this StackOverflow post: stackoverflow.com/questions/63072927/how-to-inject-application-context-in-a-repository-with-hilt
@GCkk4 ай бұрын
@@TheAndroidFactory Sorry I think Question was not clear. I wish inject the applicationContext of the app to a library module.
@TheAndroidFactory4 ай бұрын
@GCkk yeah it could be done by defining an interface in the library module that needs application context, and is implemented in the app module. I'd consider alternate ways of doing this as well though as a thought exercise, for instance: do you actually need the application context as opposed to another context? Is there a way you can restructure things so whatever needs the application context can be injected into the library as opposed to the library requiring the context itself? It may not be wrong what you're doing, but it may be easier if you try to solve the problem a different way. Just something to think about! Hope this helps