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

Improve BlocDelegate Initialization #304

Closed
felangel opened this issue May 17, 2019 · 4 comments
Closed

Improve BlocDelegate Initialization #304

felangel opened this issue May 17, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request
Projects

Comments

@felangel
Copy link
Owner

Is your feature request related to a problem? Please describe.
Setting a custom BlocDelegate is a bit confusing in its current state.
We need to do:

BlocSupervisor().delegate = MyBlocDelegate()

This makes it seem like we are creating a new instance of the BlocSupervisor when instead we are retrieving a reference to the singleton instance.

Describe the solution you'd like
It would be a bit more intuitive to initialize the delegate like:

BlocSupervisor.delegate = MyBlocDelegate();
@felangel felangel added the enhancement New feature or request label May 17, 2019
@felangel felangel self-assigned this May 17, 2019
@felangel felangel added this to In progress in bloc May 17, 2019
@felangel felangel moved this from In progress to Done in bloc May 17, 2019
@felangel
Copy link
Owner Author

Merged in #305 and will be included in bloc v0.14.0

@AlejandroC90
Copy link

I'm having trouble creating my own BlocDelegate, when overriding onTransition I get an error, did the annotation change? Thanks

@felangel
Copy link
Owner Author

@AlejandroC90 can you please share your BlocDelegate code as well as the error you’re getting? Thanks!

@AlejandroC90
Copy link

Sorry for late response, but I was just getting and error with the old BlocDelegate.
class SimpleBlocDelegate extends BlocDelegate {
@override
void onTransition(Transition transition) {
print(transition.toString());
}
}

Didnt know that I had to update it to:

class SimpleBlocDelegate extends BlocDelegate {
@override
void onTransition(Bloc bloc, Transition transition) {
super.onTransition(bloc, transition);
print(transition);
}
}

Thanks for the response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
bloc
  
Done
Development

No branches or pull requests

2 participants