Thoughts
tenhobi opened this issue · comments
- Why is the
cubic<A>()
extension a method and not a getter, ergocontext.cubic<A>
? https://github.com/felangel/cubit/blob/master/packages/flutter_cubit/lib/src/cubit_provider.dart#L148 - We should use
Object
rather thandynamic
. (And I just noticed we usedynamic
also in Bloc)
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