Bloc: Why mapEventToState have currentState?

Created on 24 Mar 2019  路  2Comments  路  Source: felangel/bloc

Hello

Why do you use currentState in mapEventToState if currentState is a property of bloc and can be access with the same way without be a parameter of mapEventToState

Thanks.

 @override
  Stream<int> mapEventToState(int currentState, CounterEvent event) async* {
    yield currentState +1;
  }

the same as this

 @override
  Stream<int> mapEventToState( CounterEvent event) async* {
    yield currentState +1;
  }
enhancement

Most helpful comment

@GiancarloCode thanks for bringing this up! Originally, blocs didn't have a currentState property so the mapEventToState method needed it. Now that currentState is a property in all Blocs it is no longer needed.

162 will address this and it will be included in the next release (v0.11.0).

Thanks again for bringing this up! I totally forgot to make this simplification after adding currentState property.

All 2 comments

@GiancarloCode thanks for bringing this up! Originally, blocs didn't have a currentState property so the mapEventToState method needed it. Now that currentState is a property in all Blocs it is no longer needed.

162 will address this and it will be included in the next release (v0.11.0).

Thanks again for bringing this up! I totally forgot to make this simplification after adding currentState property.

published in bloc v0.11.0 馃帀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timtraversy picture timtraversy  路  3Comments

komapeb picture komapeb  路  3Comments

Reidond picture Reidond  路  3Comments

abinvp picture abinvp  路  3Comments

wheel1992 picture wheel1992  路  3Comments