KotlinBloc
KotlinBloc copied to clipboard
BlocViewModel?
I really liked your implementation of Bloc in kotlin.
ViewModel is finely integrated with Activities (retention on activity recreate, etc) and other Android stuff in general. Also ViewModel is responsible for holding the ui state, and reacting to ui actions (just like Bloc).
So, a BlocViewModel based on AndroidViewModel/ViewModel would be great and really useful.
BlocViewModel would be a AndroidViewModel/ViewModel with all capabilities of Bloc.
Your thoughts?
I think it should use viewmodel as you have suggested. For me the most important reason to use viewmodel is to use hilt.
I like this suggestion - I'll look into it!
I like this suggestion - I'll look into it!
Amazing. This will be really helpful as we will be able to use hilt, scopes and other cool stuff. Plus if google adds more features to viewmodel, we will be able to adopt them easily. Looking forward for an update.
I have looked into the library and the it can be achieved by exteneding BlocBase with ViewModel.
abstract class BlocBase<State>(initial: State)
But another serious issue arises here that KotlinBloc which is platform independent, becomes specific to android only. Maybe a separate library like com.github.ptrbrynt.KotlinBloc:viewmodel which would be specific to android. It's a suggestion. There might be other solutions to this as well.