spawn<S> method
Creates a new Class Instance S
from the builder callbackS
.
Every time find<S
>() is used, it calls the builder method to generate
a new Instance S
.
It also registers each instance.onClose()
with the current
Route June.reference
to keep the lifecycle active.
Is important to know that the instances created are only stored per Route.
So, if you call June.delete<T>()
the "instance factory" used in this
method (June.spawn<T>()
) will be removed, but NOT the instances
already created by it.
Example:
Repl a = find();
Repl b = find();
print(a==b); (false)```
Implementation
void spawn<S>(
BuilderPattern<S> builder, {
String? tag,
bool permanent = true,
}) {
_insert(
isSingleton: false,
name: tag,
builder: builder,
permanent: permanent,
);
}