-
Notifications
You must be signed in to change notification settings - Fork 5
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
Review Public API #1
Comments
Update:
Checking for meta-annotation requires loading the annotation class type, which is a little more expensive that simply reading the AST of the annotated class Now, the proposal in this issue takes a different direction, and follows this (simplified):
This makes all the difference It's a classic performance vs UX problem 😄 Given these concerns, we'd like some external opinions to give insight into potential use cases so that we can have a wholistic view that would help us make the most informed decision |
Regarding ContributesAndroidBinding, ContributesAndroidInjection: |
What do you think about using |
This is interesting Take a look at this code @ContributesAndroidBinding
class MyActivity: Activity() The compiler can immediately figure out from this, that Keep in mind that we're actually generating a BindingModule for the type, and scope only informs where we should install that module Consider this from another perspective. Usually, scope as a parameter is never optional. Scope annotations (SingleIn, ForScope, etc), Contributes annotations (ContributesTo, ContributesBinding, etc). Even though with ContributesBinding, compiler can already figure out the type, we still have to supply a scope because they serve different purposes Lastly, in an error case where we can't figure out the super type, and user also hasn't supplied a "scope", we fail with an error that asks them to help us because we couldn't figure out the scope because we were looking for it by the type What do you think? |
I went ahead to give this a try: #18 I still feel a bit of doubt though, for reasons I haven't been able to properly articulate, besides what I already mentioned |
Closing as won't do. An alternative solution is now implemented in #60 |
Our current API is working fine for our needs, but we may be able to improve it aiming to reduce cognitive load of developers using the library for the first time. For example, instead of multiple annotations we could come up with a couple of annotations and make the compiler smarter enough to understand what type is annotating.
The following proposal recommends:
For cases where "injection" is not required:
As you can see, we can pretty much infer the target type and reduce all features to a couple of annotations:
ContributesAndroidInjection
for members injection andContributesAndroidBinding
for constructor injection (by using assisted injection).We could also validate by type on the compiler level and by including a custom lint rule.
The text was updated successfully, but these errors were encountered: