replace<T extends Model> static method

void replace<T extends Model>(
  1. ModelBuilder<T> builder, [
  2. String? id
])

Replaces an existing model from the store with the same type of the given model.

Note that Store.add doesn't replace a model if it already exists. Instead it silently ignores the request. So use this method for replacing an entire model. Use the id parameter to replace an instance of id model. See Store.add for details.

Implementation

static void replace<T extends Model>(ModelBuilder<T> builder, [String? id]) {
  final key = id ?? T;
  _LazyModelStore.replace(builder, key);
  _EagerModelStore.replace(builder(), key);
}