-
Notifications
You must be signed in to change notification settings - Fork 44
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
KSP: use KSP to generate ViewModel boilerplate code #32
Conversation
Cleans up USF VM generation pattern to more closely match hand written
app: MSApp, | ||
movieRepo: MSMovieRepository, | ||
coroutineScope: CoroutineScope? = null, | ||
) : AndroidViewModel(app), UsfVm<MSMovieEvent, MSMovieResult, MSMovieViewState, MSMovieViewEffect> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored generated ViewModel: no longer implements UsfVm
interface, simplifying KSP logic. This change is transparent from an API user perspective. Future modifications may bring KSP generation code closer to this approach.
@CubanAzcuy was not comfortable with some of the hard-coding that was required in the ksp gen code, to enable the implementation of the interface.
This PR aims to use KSP to generate the boilerplate code needed for the
FeatureVM
class. The way the UDF model works here is that you just write the code for theFeatureVMImpl
with the event → result → state/effect transformations and KSP takes care of the rest.UsfViewModelProcessor
has the interesting code and implementsSymbolProcessor
that processes all objects annotated with@UsfViewModel
SymbolProcessorProvider
file and register it in yourMANIFEST/services
directoryMSMovieVM
generated automatically fromMSMovieVMImpl
by just annotatingMSMovieVMImpl
with@UsfViewModel
Many thanks to @CubanAzcuy for help with this 🙏🏽