updateDifferentTypes method
void
updateDifferentTypes(
- List<
RepoUpdateType> updateTypes, { - List<
Id> ? ids, - List<
Model> ? models,
This functions notify in _repositoryStream
that are a change in the models
in repositoryMap
You can use ids
to update a list of ids or you can use models
to update
a list of models.
Is needed the updateTypes
list in the order of the ids or models to
set the update type in each model.
! Not use this function outside the repositories
In the extended class, this function has to be called always for the models obtained from the database. (like getFromId)
Implementation
void updateDifferentTypes(List<RepoUpdateType> updateTypes,
{List<Id>? ids, List<Model>? models}) {
if (ids == null && models == null) return;
List<RepoUpdate> updates = [];
for (int i = 0; i < updateTypes.length; i++) {
if (ids != null) {
updates.add(RepoUpdate<Id>(
modelId: ids[i],
type: updateTypes[i],
));
} else {
updates.add(RepoUpdate<Id>(
modelId: models![i].id,
type: updateTypes[i],
));
}
}
_repositoryStream.add(updates as List<RepoUpdate<Id>>);
}