setGroup method
Updates the state by setting or replacing the group under the
specified groupEntity.
Implementation
void setGroup(
TDependencyGroup<Object> group, {
Entity groupEntity = const DefaultEntity(),
}) {
final currentGroup = _state[groupEntity];
final equals = const MapEquality<Entity, Dependency>().equals(
currentGroup,
group,
);
if (!equals) {
if (currentGroup != null) {
for (final typeEntity in currentGroup.keys) {
_detachFromTypeIndex(typeEntity, groupEntity);
}
}
_state[groupEntity] = group;
for (final typeEntity in group.keys) {
(_typeIndex[typeEntity] ??= <Entity>{}).add(groupEntity);
}
_fireOnChange();
}
}