Hi,
I've a use case where the user clicks on a button but if a given validation does not pass then the state will remain the same however, I'd like to show an alert dialog always. For example, login form where the user does not input a valid email but presses the recover password button.
I know there are other approaches in terms of UX that could avoid this need but for me, having the bloc filtering duplicated state transitions for this case does not allows me to implement the desired behaviour.
So, my questions is: I'm using the Bloc pattern incorrectly here or the duplicate filter should be optional on the bloc ?
thanks in advance,
Hi @vitor-gyant thanks for opening an issue!
You should be able to accomplish this; however you need to make sure you are not extending Equatable in your states and that you are yielding a new state instance in your bloc. Let me know if that helps. If not, it鈥檇 be great if you could share a sample app that exhibits the problem you鈥檙e having and I can take a look 馃憤
Thanks @felangel for the quick reply.
So basically by not extending from Equatable I'd only loose the compare functionality which implicitly will disable the filter. Is this the correct interpretation ?
Thanks,
@vitor-gyant no problem!
Yes, if you don't extend Equatable and yield a new instance of the state it will be interpreted as being different based on the way Dart equality comparisons work. Check out the Dart Documentation for more information about this. 馃憤
Closing this for now but feel free to comment with additional questions if they arise and I'll reopen it.
@felangel Hi, so much thanks for awesome project, I have a bloc which yields multiple states of the same type but with different payloads. the bloc builder will not rebuild my widgets unless I omit extending from Equatable then everything works fine.
I guess we should add this as a point in docs write below this part in
https://felangel.github.io/bloc/#/coreconcepts?id=states

I would be happy to make a PR for this if it seems okay to you.
Hi @bardiarastin thanks for the positive feedback!
Regarding your question, can you share your state class implementation? I'm guessing you're not passing the properties to the super class. You should be able to have everything work as expected when extending Equatable.
Most helpful comment
@vitor-gyant no problem!
Yes, if you don't extend
Equatableand yield a new instance of the state it will be interpreted as being different based on the way Dart equality comparisons work. Check out the Dart Documentation for more information about this. 馃憤Closing this for now but feel free to comment with additional questions if they arise and I'll reopen it.