create<E extends Entity> method
RepositoryScope<E>
create<E extends Entity>(
- E entity,
- RepositorySubscription<
E> subscription, { - bool deleteIfExists = false,
Implementation
RepositoryScope<E> create<E extends Entity>(
E entity,
RepositorySubscription<E> subscription, {
bool deleteIfExists = false,
}) {
for (final scope in _scopes.keys) {
if (_scopes[scope] is E) {
if (deleteIfExists) {
_scopes.remove(scope);
} else {
final _scope = scope as RepositoryScope<E>;
scope.subscription = subscription;
return _scope;
}
break;
}
}
final scope = RepositoryScope(subscription);
_scopes[scope] = entity;
return scope;
}