You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some static instances extending DataCenter, which holds a Map<String, ModelWrapperState>.
In that way, no matter how many places use a story model, as long as model they are using has the same key, they are using the same model.
However, this map is going to be very big, because ModelWrapperCubit can't know whether there is no BlocBuilder using them, so it can't be called close().
Desired Solution
In fact, BlocBase use StreamController to dispatch state. And StreamController.onCancel() is called when there is no active subscriber. So maybe we can expose this callback to Cubit and Bloc level, so that they can know when to release themselves.
The text was updated successfully, but these errors were encountered:
Description
I'm using Cubit as a model that supports auto refresh, like codes below:
`@freezed
class ModelWrapperState with _$ModelWrapperState {
const factory ModelWrapperState.initial() = _ModelInitial;
const factory ModelWrapperState.loaded(T value, int expiredAt) = _ModelLoaded;
const factory ModelWrapperState.expired(T value) = _ModelExpired;
const factory ModelWrapperState.error() = _ModelError;
const ModelWrapperState._();
}`
I have some static instances extending DataCenter, which holds a Map<String, ModelWrapperState>.
In that way, no matter how many places use a story model, as long as model they are using has the same key, they are using the same model.
However, this map is going to be very big, because ModelWrapperCubit can't know whether there is no BlocBuilder using them, so it can't be called close().
Desired Solution
In fact, BlocBase use StreamController to dispatch state. And StreamController.onCancel() is called when there is no active subscriber. So maybe we can expose this callback to Cubit and Bloc level, so that they can know when to release themselves.
The text was updated successfully, but these errors were encountered: