Comments (10)
To contributors,
I was trying to investigate on adopting auto dagger in my project but unfortunately had to abandon due to lack of support to SubComponent creation. Is it something that is in your roadmap to implement?
Implementing nested components requires the implementation of methods that provide instantiation of the sub-component at the top level component e.g.: -
AuthenticationComponent authenticationComponent(AuthenticationModule authenticationModule);
GameComponent gameComponent(GameModule gameModule);
Thanks
Neville.
from auto-dagger2.
@nbonavia @ersin-ertan
Hey guys, sorry for the slow reaction on this.
I just added support for subcomponents with a new annotation @AutoSubcomponent
.
It works in the same way as @AutoComponent
.
The attribute addsTo
defines to which component the current subcomponent will be added to:
// Will generate MySubObjectComponent class which be itself annotated with @Subcomponent
@AutoSubcomponent(addsTo = MyApp.class)
@DaggerScope(MySubObject1.class)
public class MySubObject1 {
}
I published the 1.2-SNAPSHOT version with the subcomponent support.
You need to add the snapshot repository:
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
Let me know if that solves your case, and if all is good I'll release the 1.2 version to maven central.
Thanks!
from auto-dagger2.
Hey Lukas, thanks for the update and the new annotation. Unfortunately I will not be able to verify this for ~1 month. If @nbonavia or someone else could step up and try it out with feedback that would be great, for version 1.2, and closing the issue.
from auto-dagger2.
hi @ersin-ertan and @lukaspili ,
I am planning to verify this very shortly, typically this week or maybe the next one. I will be sending you feedback shortly.
Thanks for your response
@nbonavia
from auto-dagger2.
That's cool :) Thanks
from auto-dagger2.
Quick Question @lukaspili , how can I inform the Component which are its sub-components so that it'll automatically create interfaces to create the Dagger Sub-Component instances?. Typical Component to sub-component interface links are as shown below: -
AuthenticationComponent authenticationComponent(AuthenticationModule authenticationModule);
GameComponent gameComponent(GameModule gameModule);
Can these be auto-generated using autodagger?
Neville.
from auto-dagger2.
@nbonavia I realized I wrote the implementation following the inverse logic, starting from @AutoSubcomponent, which was wrong.
I just pushed a new 1.2-SNAPSHOT version with new API changes:
Step 1. Generate the subcomponent if you need, or you can use manually created Subcomponent.
// Will generate MySubObjectComponent class which be annotated with @Subcomponent
@AutoSubcomponent
@DaggerScope(MySubObject1.class)
public class MySubObject1 {
}
Step 2. Add the subcomponent to the @AutoComponent
// Will generate FirstActivityComponent with a subcomponent for MySubObject1
@AutoComponent(
subcomponents = MySubObject1.class
)
@DaggerScope(FirstActivity.class)
public class FirstActivity extends Activity {
}
from auto-dagger2.
Hi @lukaspili,
Nice work with the library. I'm working with @nbonavia and was thinking I would try your project out.
Is the 1.2-SNAPSHOT available on Github?
from auto-dagger2.
It's available as maven jar in the sonatype snapshot repository.
You need to add the repository in your gradle config first, and then you can use the dependency as usual.
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
apt 'com.github.lukaspili.autodagger2:autodagger2-compiler:1.2-SNAPSHOT'
compile 'com.github.lukaspili.autodagger2:autodagger2:1.2-SNAPSHOT'
}
from auto-dagger2.
Hey dude, this is awesome work but i see lack of two functionalities about autosubcomponents.
Firstly, it's not possible to use module with non empty default constructor. Autodagger generates plus-method for specified subcomponent but without module as parameter.
Secondly, autosubcomponent annotation does not provide option to specify subcomponents on itself. It's impossible to do something like this: @AutoSubcomponent(subcomponents = arrayOf(Subcomponent2::class))
I'm sure that I will use auto-dagger2 in the future if these two issues will be solved. Best regards from Poland
from auto-dagger2.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auto-dagger2.