From e5848784ac8e4857d5a515ff1c81b2a021a5d143 Mon Sep 17 00:00:00 2001 From: Sergey Penkovsky Date: Fri, 8 Aug 2025 16:56:37 +0300 Subject: [PATCH] refactor(core): make closeRootScope async and await dispose BREAKING CHANGE: closeRootScope is now async (returns Future and must be awaited). This change improves resource lifecycle management by allowing asynchronous cleanup when disposing the root Scope. All usages of closeRootScope should be updated to use await. - Change closeRootScope from void to Future and add async keyword - Await _rootScopefor correct async disposal - Ensures proper disposal and better future extensibility for async resources Closes #xxx (replace if issue exists) --- cherrypick/lib/src/helper.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cherrypick/lib/src/helper.dart b/cherrypick/lib/src/helper.dart index 3795904..0828b73 100644 --- a/cherrypick/lib/src/helper.dart +++ b/cherrypick/lib/src/helper.dart @@ -94,9 +94,9 @@ class CherryPick { /// ```dart /// CherryPick.closeRootScope(); /// ``` - static void closeRootScope() { + static Future closeRootScope() async { if (_rootScope != null) { - _rootScope!.dispose(); // Автоматический вызов dispose для rootScope! + await _rootScope!.dispose(); // Автоматический вызов dispose для rootScope! _rootScope = null; } } @@ -252,9 +252,9 @@ class CherryPick { /// CherryPick.closeScope(scopeName: 'network.super.api'); /// ``` @experimental - static void closeScope({String scopeName = '', String separator = '.'}) { + static Future closeScope({String scopeName = '', String separator = '.'}) async { if (scopeName.isEmpty) { - closeRootScope(); + await closeRootScope(); return; } final nameParts = scopeName.split(separator); @@ -267,9 +267,9 @@ class CherryPick { openRootScope(), (Scope previous, String element) => previous.openSubScope(element) ); - scope.closeSubScope(lastPart); + await scope.closeSubScope(lastPart); } else { - openRootScope().closeSubScope(nameParts.first); + await openRootScope().closeSubScope(nameParts.first); } }