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

clicksocial picture clicksocial  路  3Comments

nhwilly picture nhwilly  路  3Comments

hivesey picture hivesey  路  3Comments

ricktotec picture ricktotec  路  3Comments

timtraversy picture timtraversy  路  3Comments