-
-
Notifications
You must be signed in to change notification settings - Fork 26
[DISCUSSION] Should Cubit expose Stream API? #46
Comments
Hi @chimon2000 👋 Can you please elaborate a bit on why you feel surfacing the Stream API is undesirable? In my opinion, this makes cubit (and bloc) a lot more versatile and powerful. Thanks 😄 |
I agree it makes it more powerful, but I also think the trade-off is added complexity most users may not care about. I don't think that the developer should need to know anything about Streams (which they don't) to use Cubit, however when you're intellisense presents you with the entire Stream API it might appear daunting. If the stream is a protected variable, that may be a way to convey to the user: "only use this if you really know what you're doing." I also acknowledge that this is subjective and influenced by my initial reaction to seeing everything but state & init in my IDE. 😊 |
Thanks for clarifying! I see what you're saying and would love to hear what other members of the community think. If most individuals would rather not have the Stream API at the surface level of Cubit we can easily move it one level lower but it would technically be a breaking change and it would not be consistent with bloc which also extends Thoughts? |
Definitely should surface this one to the larger community. I guess I should have opened this issue before I suggested integrating bloc & cubit 😅 |
Haha no worries! I'll think about this some more and wait to hear what the rest of the community thinks 👍 One thing to note is you typically shouldn't need to use |
Yeah, I was actually just using this for simulation purposes, I'm pretty sure i discovered this by accident while emitting a change. |
To me it looks more like a discussion about whether or not But that's not feasible because you won't be able to extend bloc from If we'd to adhere to dart primitives design then having a |
I think that ideally, I'd want I'm not sure how much it matters / how valid this is, but another potential thing to consider is that if I don't feel that strongly about this, but that's my 2 cents. |
@samandmoore |
Hm. That's surprising to me that it would go against the dart primitives design. To me, it seems like easily being able to convert a value into a related but different value, e.g. a future to a stream, or in our case, a cubit/Bloc to a stream, would be a good feature of this specific primitive. |
Definitely trade offs here though 🤔 |
moved to felangel/bloc#1429 |
Something I immediately noticed is that because Cubit inherits from Stream, it surfaces the entire Stream API. This seems like a leaky abstraction, and I'm wondering whether there is some way that the API could be hidden?
One option I could see is for
Cubit
to have a protected/privateCubitStream<State>
stream property, rather than inherit from it. The most minimal change might be something like the following.The text was updated successfully, but these errors were encountered: