Hello 馃榿
In which cases I don't need to Extends
Equatable
(or override the == operator as well as hashCode)?
I use ever, but i don't know if i did it correct o simply i am adding more code :(
If I have a State
that Extends Equatable
and this state have an other class like property, I need to extend Equatable also in this property?
Thanks
class State extends Equatable{
final Car car
State(this.car): super([car]);
}
class Car{
String type;
String model;
String color;
}
Thanks 馃
Hey @basketball-ico 馃憢
Equatable
. If you want to optimize your application to avoid rebuilding if the state doesn't change you can extend Equatable
.State
you'd need to either have Car
extend Equatable
or have manually override ==
and hashCode
.Hope that helps! 馃憤
Thanks I got it :D.
But i can't understand why you extends Equatable
in theEvents
of your examples.
I see that you compare the states if (currentState == nextState) return;
but not the events.
Thanks
@basketball-ico great question! 馃挴
I extend Equatable
in events as well because it makes it possible to do things like override transform
in the bloc and manipulate the stream of events (using operators like debounce, distinct, etc..). Otherwise everything is technically a new/different Event
.
Does that help?
Yeah, so for confirm :D, if I not need to override transform
, not are any reason for extends Equatable
in events. I am right?
Thanks ;D
@basketball-ico that's correct 馃憤
Most helpful comment
Hey @basketball-ico 馃憢
Equatable
. If you want to optimize your application to avoid rebuilding if the state doesn't change you can extendEquatable
.State
you'd need to either haveCar
extendEquatable
or have manually override==
andhashCode
.Hope that helps! 馃憤