Review Public API
See original GitHub issueOur 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:
// Members Injection.
@ContributesAndroidInjection
class MyApplication : Application() {
fun onCreate() {
Whetstone.inject(application = this)
}
}
@ContributesAndroidInjection
class MyActivity : Activity() {
fun onCreate() {
Whetstone.inject(activity = this)
}
}
@ContributesAndroidInjection
class MyService : Service() {
fun onCreate() {
Whetstone.inject(service = this)
}
}
// Constructor Injection.
@ContributesAndroidBinding
class MyFragment @Inject constructor() : Fragment()
@ContributesAndroidBinding
class MyViewModel @Inject constructor() : ViewModel()
@ContributesAndroidBinding
class MyWorkManager @Inject constructor() : WorkManager()
For cases where “injection” is not required:
Whetstone.install(application = this)
Whetstone.install(activity = this)
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 and ContributesAndroidBinding
for constructor injection (by using assisted injection).
We could also validate by type on the compiler level and by including a custom lint rule.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Review API | Fast & reliable review scraping from over 30+ ...
Use our free Review API to scrape structured and normalized JSON review data from 10+ review platforms to build your apps or custom...
Read more >Work with review data | Google Business Profile APIs
This tutorial shows you how to list, return, reply, and delete a review. The Google My Business API provides you with the ability...
Read more >109 Ratings APIs (2022) - ProgrammableWeb
The ReviewPro API allows you access to review data. This includes services for; Lodging GRI and Source Rating Indexes, Average scores, GRS Rating...
Read more >How to Conduct an API Design Review - Tyk.io
Why API design reviews? · A word of caution before you proceed · Start with the documentation · Focus on the 'why' of...
Read more >Online Reviews API | Reputation Management API | 80+ Sites
Online Reviews & Reputation API. Get online review counts, ratings, and content from 80 review sites, including Google, Yelp, Facebook, and TripAdvisor. Reviews...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Update: Currently, we have specialized annotations for different components. E.g ContributesFragment, ContributesViewModel, etc We also recently switched to automatic discovery of these annotations, so we don’t have to hard code them in the compiler The approach to discovery is as follows (simplified):
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 For (1), there’s only a finite set of unique annotations, and we can cache the necessary info from any previously loaded one. However, loading full classes and their super types doesn’t lend themselves so much to caching (again loading types is more expensive that reading source AST). Best case, no need to do any loading if a class directly extends any of the known types. Worst case, a significant amount of super class loading until we finally get to the known types or nothing (we should always fail in case of nothing)
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
Closing as won’t do. An alternative solution is now implemented in #60