When I link child scopes to a parent scope, will the child scopes get closed automatically, when I close the parent scope? I suspect not, that's why I did the following and it seems to work well: When creating the children, I link them to the parent scope. As I keep all children in a repository which is part of the parent scope, I just close all child scopes when the parent scope is closed via callback. I was wondering if there is another, better approach?
module {
scope<Parent> {
scoped { ChildRepository() }.onClose { childRepository ->
childRepository?.children?.forEach { child ->
child.scope.close()
}
}
}
scope<Child> {
...
}
}