Bloc update 6.1.0
Attempt to solve #148 (closed) Most Changes of the newer Bloc Version are now included.
But there are some non-trivial changes left.
Basically every open issue has to do with the following:
initialState
now was removed and instead of overriding this, the initialState
of a Bloc should be provided via the constructor.
For example:
UserBloc() : _httpRepo = HttpRepository();
@override
UserState get initialState => _fix(super.initialState) ?? UserLoggedOutState();
UserState _fix(UserState persistedState){
// Do some internal logic.
}
The code above does not work with the new changes as it should look like this:
UserBloc()
: _httpRepo = HttpRepository(),
super(UserLoggedOutState());
The problem is, that you now no longer have access to the persisted state inside of the bloc and thus cannot just call the _fix()
method.
If i find a nice way to implement similar behaviour i will update this.
Currently the Bloc's where we have to fix this are:
-
HomeBloc -
UserBloc
-
VCardBloc // ? Maybe maybe not ?
-
CafeteriaBloc -
CafeteriaOpeningBloc -
CafeteriaSettingsBloc
-
OCalendarBloc -
OColorMappingBloc -
OLessonSelectionBloc -
OProgramConfigurationBloc -
OProgramHistoryBloc
-
Final Testing -
-
Every Calendar-Bloc seemingly resets after the update. Need some help for further debugging @mlbn33
-
-
We discovered that the runtime type is not persisted. For example in the app OProgramConfigurationState
is never expected, but thefromJson
doesn't know which state should be rebuilt. It should rebuildOProgramConfigurationEmptyState
OROProgramConfigurationReadyState
, but neither does, because it acceptsOProgramConfigurationState
as default. We need to be able to also save the state class/runtime type.
return OProgramConfigurationState.fromJson(json);
Edited by Justin Sauer