delete<T extends Object?> method
Deletes the instance from instances but keep the builder
function.
Returns true
when the instance has been deleted.
Implementation
bool delete<T extends Object?>([String? id, Object? ref]) {
final instanceToFind = ReactterInstance<T?>(id);
final instanceFound =
_reactterInstanceManager.instances.lookup(instanceToFind);
if (instanceFound == null || instanceFound.instance == null) {
Reactter.log(
'Instance "$instanceToFind" already deleted.',
isError: true,
);
return false;
}
if (ref != null) {
instanceFound.refs.remove(ref.hashCode);
}
if (instanceFound.refs.isNotEmpty) {
return false;
}
_removeInstance<T>(instanceFound);
UseEvent<T>(id).dispose();
return true;
}