diff --git a/packages/dispose_scope/README.md b/packages/dispose_scope/README.md index 11b53d4..bf5b4e5 100644 --- a/packages/dispose_scope/README.md +++ b/packages/dispose_scope/README.md @@ -13,10 +13,10 @@ import 'package:dispose_scope/dispose_scope.dart'; final disposeScope = DisposeScope(); // StreamSubscription will be cancelled when disposeScope is disposed -const Stream.empty().listen((event) {}).disposed(disposeScope); +const Stream.empty().listen((event) {}).disposedBy(disposeScope); // Timer will be cancelled when disposeScope is disposed -Timer(Duration.zero, () {}).disposed(disposeScope); +Timer(Duration.zero, () {}).disposedBy(disposeScope); disposeScope.dispose(); ``` diff --git a/packages/dispose_scope/example/main.dart b/packages/dispose_scope/example/main.dart index 40f17ca..97ed4fb 100644 --- a/packages/dispose_scope/example/main.dart +++ b/packages/dispose_scope/example/main.dart @@ -6,10 +6,10 @@ void main() { final disposeScope = DisposeScope(); // StreamSubscription will be cancelled when disposeScope is disposed - const Stream.empty().listen((dynamicevent) {}).disposed(disposeScope); + const Stream.empty().listen((dynamicevent) {}).disposedBy(disposeScope); // Timer will be cancelled when disposeScope is disposed - Timer(Duration.zero, () {}).disposed(disposeScope); + Timer(Duration.zero, () {}).disposedBy(disposeScope); disposeScope.dispose(); } diff --git a/packages/dispose_scope/lib/src/disposable.dart b/packages/dispose_scope/lib/src/disposable.dart index 788375c..e54b43a 100644 --- a/packages/dispose_scope/lib/src/disposable.dart +++ b/packages/dispose_scope/lib/src/disposable.dart @@ -3,7 +3,7 @@ import 'package:dispose_scope/dispose_scope.dart'; /// An object that can be disposed. abstract class Disposable { /// Adds this object to [disposeScope]. - void disposed(DisposeScope disposeScope) { + void disposedBy(DisposeScope disposeScope) { disposeScope.addDispose(dispose); } diff --git a/packages/dispose_scope/lib/src/disposed_extensions/connection_task_disposed.dart b/packages/dispose_scope/lib/src/disposed_extensions/connection_task_disposed.dart index 6cf5663..3bb29b2 100644 --- a/packages/dispose_scope/lib/src/disposed_extensions/connection_task_disposed.dart +++ b/packages/dispose_scope/lib/src/disposed_extensions/connection_task_disposed.dart @@ -7,7 +7,7 @@ extension ConnectionTaskDisposed on ConnectionTask { /// Adds this connection task to [disposeScope]. /// /// It will be canceled when [disposeScope] is disposed. - void disposed(DisposeScope disposeScope) { + void disposedBy(DisposeScope disposeScope) { disposeScope.addDispose(() async => cancel()); } } diff --git a/packages/dispose_scope/lib/src/disposed_extensions/dispose_scope_disposed.dart b/packages/dispose_scope/lib/src/disposed_extensions/dispose_scope_disposed.dart index d21883e..78f9179 100644 --- a/packages/dispose_scope/lib/src/disposed_extensions/dispose_scope_disposed.dart +++ b/packages/dispose_scope/lib/src/disposed_extensions/dispose_scope_disposed.dart @@ -11,7 +11,7 @@ extension DisposeScopeDisposed on DisposeScope { /// Adds this dispose scope to [parentDisposeScope]. /// /// It will be disposed when [parentDisposeScope] is disposed. - void disposed(DisposeScope parentDisposeScope) { + void disposedBy(DisposeScope parentDisposeScope) { if (parentDisposeScope == this) { throw Exception( ''' diff --git a/packages/dispose_scope/lib/src/disposed_extensions/process_disposed.dart b/packages/dispose_scope/lib/src/disposed_extensions/process_disposed.dart index 9de88f3..bc27886 100644 --- a/packages/dispose_scope/lib/src/disposed_extensions/process_disposed.dart +++ b/packages/dispose_scope/lib/src/disposed_extensions/process_disposed.dart @@ -7,7 +7,7 @@ extension ProcessDisposed on Process { /// Adds this process to [disposeScope]. /// /// It will be killed when [disposeScope] is disposed. - void disposed(DisposeScope disposeScope) { + void disposedBy(DisposeScope disposeScope) { disposeScope.addDispose(() async => kill()); } } diff --git a/packages/dispose_scope/lib/src/disposed_extensions/sink_disposed.dart b/packages/dispose_scope/lib/src/disposed_extensions/sink_disposed.dart index a32f71c..bd1c960 100644 --- a/packages/dispose_scope/lib/src/disposed_extensions/sink_disposed.dart +++ b/packages/dispose_scope/lib/src/disposed_extensions/sink_disposed.dart @@ -5,7 +5,7 @@ extension SinkDisposed on Sink { /// Adds this sink to [disposeScope]. /// /// It will be closed when [disposeScope] is disposed. - void disposed(DisposeScope disposeScope) { + void disposedBy(DisposeScope disposeScope) { disposeScope.addDispose(() async => close()); } } diff --git a/packages/dispose_scope/lib/src/disposed_extensions/stream_subscription_disposed.dart b/packages/dispose_scope/lib/src/disposed_extensions/stream_subscription_disposed.dart index 5a37a49..6bc9e1a 100644 --- a/packages/dispose_scope/lib/src/disposed_extensions/stream_subscription_disposed.dart +++ b/packages/dispose_scope/lib/src/disposed_extensions/stream_subscription_disposed.dart @@ -7,7 +7,7 @@ extension StreamSubscriptionDisposed on StreamSubscription { /// Adds this stream subscription to [disposeScope]. /// /// It will be canceled when [disposeScope] is disposed. - void disposed(DisposeScope disposeScope) { + void disposedBy(DisposeScope disposeScope) { disposeScope.addDispose(() async => cancel()); } } diff --git a/packages/dispose_scope/lib/src/disposed_extensions/timer_disposed.dart b/packages/dispose_scope/lib/src/disposed_extensions/timer_disposed.dart index 162ea79..e28a1e7 100644 --- a/packages/dispose_scope/lib/src/disposed_extensions/timer_disposed.dart +++ b/packages/dispose_scope/lib/src/disposed_extensions/timer_disposed.dart @@ -7,7 +7,7 @@ extension TimerDisposed on Timer { /// Adds this timer to [disposeScope]. /// /// It will be canceled when [disposeScope] is disposed. - void disposed(DisposeScope disposeScope) { + void disposedBy(DisposeScope disposeScope) { disposeScope.addDispose(() async => cancel()); } } diff --git a/packages/dispose_scope/test/disposed_extensions/connection_task_disposed_test.dart b/packages/dispose_scope/test/disposed_extensions/connection_task_disposed_test.dart index 24974b3..db06d10 100644 --- a/packages/dispose_scope/test/disposed_extensions/connection_task_disposed_test.dart +++ b/packages/dispose_scope/test/disposed_extensions/connection_task_disposed_test.dart @@ -26,7 +26,7 @@ void main() { test( 'adds Dispose to DisposeScope when disposed is called', () async { - connectionTask.disposed(scope); + connectionTask.disposedBy(scope); await scope.dispose(); diff --git a/packages/dispose_scope/test/disposed_extensions/dispose_scope_disposed_test.dart b/packages/dispose_scope/test/disposed_extensions/dispose_scope_disposed_test.dart index dedee68..eaaa631 100644 --- a/packages/dispose_scope/test/disposed_extensions/dispose_scope_disposed_test.dart +++ b/packages/dispose_scope/test/disposed_extensions/dispose_scope_disposed_test.dart @@ -24,7 +24,7 @@ void main() { test( 'adds Dispose to DisposeScope when disposed is called', () async { - disposeScope.disposed(scope); + disposeScope.disposedBy(scope); await scope.dispose(); @@ -35,7 +35,7 @@ void main() { test( 'throws Exception when disposed is called with the same store', () async { - expect(() => disposeScope.disposed(disposeScope), throwsException); + expect(() => disposeScope.disposedBy(disposeScope), throwsException); }, ); }, diff --git a/packages/dispose_scope/test/disposed_extensions/sink_disposed_test.dart b/packages/dispose_scope/test/disposed_extensions/sink_disposed_test.dart index 6a381cc..a9c65ad 100644 --- a/packages/dispose_scope/test/disposed_extensions/sink_disposed_test.dart +++ b/packages/dispose_scope/test/disposed_extensions/sink_disposed_test.dart @@ -24,7 +24,7 @@ void main() { test( 'adds Dispose to DisposeScope when disposed is called', () async { - sink.disposed(scope); + sink.disposedBy(scope); await scope.dispose(); diff --git a/packages/dispose_scope/test/disposed_extensions/stream_subscription_disposed_test.dart b/packages/dispose_scope/test/disposed_extensions/stream_subscription_disposed_test.dart index 098ca34..d30bc65 100644 --- a/packages/dispose_scope/test/disposed_extensions/stream_subscription_disposed_test.dart +++ b/packages/dispose_scope/test/disposed_extensions/stream_subscription_disposed_test.dart @@ -27,7 +27,7 @@ void main() { test( 'adds Dispose to DisposeScope when disposed is called', () async { - streamSubscription.disposed(scope); + streamSubscription.disposedBy(scope); await scope.dispose(); diff --git a/packages/dispose_scope/test/disposed_extensions/timer_disposed_test.dart b/packages/dispose_scope/test/disposed_extensions/timer_disposed_test.dart index 79ff2fd..64021e8 100644 --- a/packages/dispose_scope/test/disposed_extensions/timer_disposed_test.dart +++ b/packages/dispose_scope/test/disposed_extensions/timer_disposed_test.dart @@ -26,7 +26,7 @@ void main() { test( 'adds Dispose to DisposeScope when disposed is called', () async { - timer.disposed(scope); + timer.disposedBy(scope); await scope.dispose();