felangel / cubit

Cubit is a lightweight state management solution. It is a subset of the bloc package that does not rely on events and instead uses methods to emit new states.

Home Page:https://pub.dev/packages/cubit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thoughts

tenhobi opened this issue · comments

https://github.com/felangel/cubit/blob/master/packages/flutter_cubit/lib/src/cubit_provider.dart#L8
https://github.com/felangel/cubit/blob/master/packages/flutter_cubit/lib/src/cubit_provider.dart#L33
https://github.com/felangel/cubit/blob/master/packages/flutter_cubit/lib/src/cubit_provider.dart#L108
https://github.com/felangel/cubit/blob/master/packages/flutter_cubit/lib/src/cubit_provider.dart#L148

Otherwise, I like this idea. It's just like Bloc, but it replaces Events with some kind of action methods. This also simplifies the need to check the type of Event in mapEventToStates. There should be some study etc. about Sink vs methods, but I cannot think any bad case when methods are less valuable. The main part of Bloc/Cubic is that States are immutable & distributed using Stream.

Thanks for the feedback and great point regarding the extension 👍
I'll be making those changes in cubit and hopefully will be able to deprecate and roll them into bloc shortly after 😄

Update the dynamic type in #12 but it doesn't seem extensions with generic getters are supported 😞

The following doesn't compile:

C get cubit<C extends Cubit<Object>> => CubitProvider.of<C>(this);

That actually makes sense... Getters should mimic fields's API, ergo generics are not valid. Hmm. What about late syntax? But that would also have to be field and ergo no generics, right? Damn. Nevermind. xD