Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Ensure all child modules get unloaded" #241

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions lib/src/lifecycle_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1124,20 +1124,12 @@ abstract class LifecycleModule extends SimpleModule with Disposable {
_activeSpan = _startTransitionSpan('unload');

_willUnloadController.add(this);

// We're looping here because it's possible for additional child modules to be added to this list while we are
// unloading the current items. While loadChildModule is guarded from adding new modules after unload starts,
// it contains asynchronous elements that allow a module to be added to this list during the unload.
// Note that items get removed from this list by an event handler listening to their didDispose stream.
while (_childModules.isNotEmpty) {
await Future.wait(_childModules.toList().map((child) {
child.parentContext = _activeSpan?.context;
return child.unload().whenComplete(() {
child.parentContext = null;
});
}));
}

await Future.wait(_childModules.toList().map((child) {
child.parentContext = _activeSpan?.context;
return child.unload().whenComplete(() {
child.parentContext = null;
});
}));
try {
await onUnload();
} catch (error, stackTrace) {
Expand Down
Loading