Skip to content
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

BlocViewModel? #3

Open
firefinchdev opened this issue Jan 26, 2022 · 4 comments
Open

BlocViewModel? #3

firefinchdev opened this issue Jan 26, 2022 · 4 comments

Comments

@firefinchdev
Copy link

firefinchdev commented Jan 26, 2022

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?

@zainulhassan815
Copy link

I think it should use viewmodel as you have suggested. For me the most important reason to use viewmodel is to use hilt.

@ptrbrynt
Copy link
Owner

I like this suggestion - I'll look into it!

@zainulhassan815
Copy link

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.

@zainulhassan815
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants