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

Rename Cubit to Bloc, and the current Bloc to EventBloc or similar with Bloc keyword #1570

Closed
CurrySenpai opened this issue Aug 3, 2020 · 1 comment
Assignees
Labels
duplicate This issue or pull request already exists

Comments

@CurrySenpai
Copy link

Related to #1560

Hello, I suggested this is discord a few days ago

Why not rename

  • Cubit to Bloc
  • And the current Bloc to another related to bloc like EventBloc or similar with Bloc keyword,

I think using cubit is the right decision for most cases, but the name is confusing if the bloc pattern is being implemented.

It would be an important change for current users, but I think it would help a lot of new users to use the bloc pattern, they would start using Bloc (previously Cubit), and if they have complex cases use the EventBloc (the current bloc), the api would be more related to the bloc pattern.

For example for now it sounds strange that the BlocBuilder receives a cubit

although felix said

Also cubit isn’t technically a bloc
Because there is no event sink so it’d be a bit misleading to name it Bloc imo

although technically it is true due to the implementation, we can see that Cubit is a short/easy way to use Bloc in some cases

Check #1427

Bloc
class MyBloc extends Bloc<MyState, MyState> {
  MyBloc(): super(MyState.initial());

  @override
  Stream<State> mapEventToState(MyState state) async* {
    yield state;
  }

  void someAction() {
    final nextState = _getNextState();
    add(nextState);
  }
}
Cubit
class MyBloc extends Cubit<MyState> {
  MyBloc(): super(MyState.initial());

  void someAction() {
    final nextState = _getNextState();
    emit(nextState);
  }
}

Which is why I think it would be worth considering it as a bloc despite not complying with the rule

Inputs and outputs are simple Stream/Sinks only

Related to #1560
Since now we can use the same BlocListener, BlocBuilder, and BlocConsumerforBloc(previouslyCubit) and EventBlocor similar withBlockeyword (previouslyBloc`) without having any confusion with names

@felangel
Copy link
Owner

felangel commented Aug 3, 2020

Hi @CurrySenpai 👋
Thanks for opening an issue!

I would really prefer not to do this because:

  1. It's extremely disruptive -- every resource/article/tutorial/example that previously used Bloc will no longer make sense and it will be very confusing in my opinion.

  2. It's not accurate -- a Cubit is not a Bloc (there is no event sink) so it is misleading and will lead to more confusion.

Closing this for now in favor of continuing this discussion in #1560

@felangel felangel closed this as completed Aug 3, 2020
@felangel felangel self-assigned this Aug 3, 2020
@felangel felangel added the duplicate This issue or pull request already exists label Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants