Skip to content

Commit

Permalink
Rename disposed to disposedBy in all packages (#30)
Browse files Browse the repository at this point in the history
* bloc_dispose_scope: rename `disposed` to `disposedBy`

* flutter_dispose_scope: rename `disposed` to `disposedBy`

* export extensions from `process_disposed.dart`

* update changelogs and versions

* remove unneeded `package_name` arg from `link_changelog` script
  • Loading branch information
bartekpacia authored Sep 9, 2022
1 parent efd30b3 commit 564c358
Show file tree
Hide file tree
Showing 54 changed files with 145 additions and 113 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/bloc_dispose_scope-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ jobs:
- name: Set version data
run: |
package_name=bloc_dispose_scope
tag=${{ github.ref_name }}
echo "RELEASE_NOTES=$(link_changelog $package_name $tag)" >> $GITHUB_ENV
echo "IS_PRERELEASE=$(is_prerelease $package_name $tag)" >> $GITHUB_ENV
echo "RELEASE_NOTES=$(link_changelog $tag)" >> $GITHUB_ENV
echo "IS_PRERELEASE=$(is_prerelease $tag)" >> $GITHUB_ENV
- name: Publish
run: dart pub publish -f
Expand All @@ -52,5 +51,5 @@ jobs:
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
body: ${{ env.RELEASE_NOTES }}
body: "[See changelog on pub.dev](${{ env.RELEASE_NOTES }})"
prerelease: ${{ env.IS_PRERELEASE }}
7 changes: 3 additions & 4 deletions .github/workflows/dispose_scope-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ jobs:
- name: Set version data
run: |
package_name=dispose_scope
tag=${{ github.ref_name }}
echo "RELEASE_NOTES=$(link_changelog $package_name $tag)" >> $GITHUB_ENV
echo "IS_PRERELEASE=$(is_prerelease $package_name $tag)" >> $GITHUB_ENV
echo "RELEASE_NOTES=$(link_changelog $tag)" >> $GITHUB_ENV
echo "IS_PRERELEASE=$(is_prerelease $tag)" >> $GITHUB_ENV
- name: Publish
run: dart pub publish -f
Expand All @@ -52,5 +51,5 @@ jobs:
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
body: ${{ env.RELEASE_NOTES }}
body: "[See changelog on pub.dev](${{ env.RELEASE_NOTES }})"
prerelease: ${{ env.IS_PRERELEASE }}
7 changes: 3 additions & 4 deletions .github/workflows/flutter_dispose_scope-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ jobs:
- name: Set version data
run: |
package_name=flutter_dispose_scope
tag=${{ github.ref_name }}
echo "RELEASE_NOTES=$(link_changelog $package_name $tag)" >> $GITHUB_ENV
echo "IS_PRERELEASE=$(is_prerelease $package_name $tag)" >> $GITHUB_ENV
echo "RELEASE_NOTES=$(link_changelog $tag)" >> $GITHUB_ENV
echo "IS_PRERELEASE=$(is_prerelease $tag)" >> $GITHUB_ENV
- name: Publish
run: dart pub publish -f
Expand All @@ -52,5 +51,5 @@ jobs:
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
body: ${{ env.RELEASE_NOTES }}
body: "[See changelog on pub.dev](${{ env.RELEASE_NOTES }})"
prerelease: ${{ env.IS_PRERELEASE }}
5 changes: 5 additions & 0 deletions packages/bloc_dispose_scope/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.0.0

- Upgrade `dispose_scope` dependency to 2.0.0
- Rename all `disposed()` extension methods to `disposedBy()`

## 2.0.0

- Upgraded `bloc` dependency
Expand Down
8 changes: 5 additions & 3 deletions packages/bloc_dispose_scope/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BlocDisposeScope
# bloc_dispose_scope

BlocDisposeScope adds support for bloc related types to [dispose_scope](https://pub.dev/packages/dispose_scope) package.
This package adds support for bloc related types to [dispose_scope] package.

## Usage

Expand All @@ -12,11 +12,13 @@ class MainCubit extends Cubit<String> with BlocBaseDisposeScopeMixin {
// StreamSubscription will be cancelled when MainCubit is closed
_dependencyCubit.stream
.listen(_onDependencyCubitStateChanged)
.disposed(scope);
.disposedBy(scope);
}
final DependencyCubit _dependencyCubit;
void _onDependencyCubitStateChanged(String dependencyState) {}
}
```

[dispose_scope]: https://pub.dev/packages/dispose_scope
6 changes: 3 additions & 3 deletions packages/bloc_dispose_scope/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MainCubit extends Cubit<String> with BlocBaseDisposeScopeMixin {
// StreamSubscription will be cancelled when MainCubit is closed
_dependencyCubit.stream
.listen(_onDependencyCubitStateChanged)
.disposed(scope);
.disposedBy(scope);
}

final DependencyCubit _dependencyCubit;
Expand All @@ -22,8 +22,8 @@ void main() {
final disposeScope = DisposeScope();

// Both cubits will be disposed when disposeScope is disposed
final dependencyCubit = DependencyCubit()..disposed(disposeScope);
MainCubit(dependencyCubit).disposed(disposeScope);
final dependencyCubit = DependencyCubit()..disposedBy(disposeScope);
MainCubit(dependencyCubit).disposedBy(disposeScope);

disposeScope.dispose();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:bloc/bloc.dart';
import 'package:dispose_scope/dispose_scope.dart';

extension BlocBaseDisposed<State> on BlocBase<State> {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(close);
}
}
4 changes: 2 additions & 2 deletions packages/bloc_dispose_scope/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bloc_dispose_scope
description: Package supporting bloc types for dispose_scope.
version: 2.0.0
version: 3.0.0
repository: https://github.com/RobertOdrowaz/dispose-scope/tree/master/packages/bloc_dispose_scope
issue_tracker: https://github.com/RobertOdrowaz/dispose-scope/issues
homepage: https://github.com/RobertOdrowaz/dispose-scope
Expand All @@ -10,7 +10,7 @@ environment:

dependencies:
bloc: ^8.0.0
dispose_scope: ^1.0.0
dispose_scope: ^2.0.0
meta: ^1.3.0

dev_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void main() {
test(
'adds Dispose to DisposeScope when disposed is called',
() async {
blocBase.disposed(scope);
blocBase.disposedBy(scope);

await scope.dispose();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Mocks generated by Mockito 5.3.0 from annotations
// Mocks generated by Mockito 5.2.0 from annotations
// in bloc_dispose_scope/test/disposed_extensions/bloc_base_disposed_test.dart.
// Do not manually edit this file.

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;

import 'package:bloc/bloc.dart' as _i2;
Expand All @@ -17,7 +16,6 @@ import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class

/// A class which mocks [BlocBase].
///
Expand All @@ -33,7 +31,7 @@ class MockBlocBase<State> extends _i1.Mock implements _i2.BlocBase<State> {
@override
_i3.Stream<State> get stream =>
(super.noSuchMethod(Invocation.getter(#stream),
returnValue: _i3.Stream<State>.empty()) as _i3.Stream<State>);
returnValue: Stream<State>.empty()) as _i3.Stream<State>);
@override
bool get isClosed =>
(super.noSuchMethod(Invocation.getter(#isClosed), returnValue: false)
Expand All @@ -56,6 +54,6 @@ class MockBlocBase<State> extends _i1.Mock implements _i2.BlocBase<State> {
returnValueForMissingStub: null);
@override
_i3.Future<void> close() => (super.noSuchMethod(Invocation.method(#close, []),
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value()) as _i3.Future<void>);
returnValue: Future<void>.value(),
returnValueForMissingStub: Future<void>.value()) as _i3.Future<void>);
}
6 changes: 5 additions & 1 deletion packages/dispose_scope/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.1

- Fix extensions for `Process` from `dart:io` not being exported (#30)

## 2.0.0

- Add safety checks (#25)
Expand All @@ -9,4 +13,4 @@

## 1.0.0

- Initial Release
- Initial release
1 change: 1 addition & 0 deletions packages/dispose_scope/lib/dispose_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export 'src/dispose.dart';
export 'src/dispose_scope.dart';
export 'src/disposed_extensions/connection_task_disposed.dart';
export 'src/disposed_extensions/dispose_scope_disposed.dart';
export 'src/disposed_extensions/process_disposed.dart';
export 'src/disposed_extensions/sink_disposed.dart';
export 'src/disposed_extensions/stream_subscription_disposed.dart';
export 'src/disposed_extensions/timer_disposed.dart';
7 changes: 6 additions & 1 deletion packages/flutter_dispose_scope/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.0.0

- Upgrade `dispose_scope` dependency to 2.0.0
- Rename all `disposed()` extension methods to `disposedBy()`

## 1.0.0

- Initial Release
- Initial release
4 changes: 2 additions & 2 deletions packages/flutter_dispose_scope/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class _AppState extends State<App> with StateDisposeScopeMixin {
super.initState();
// StreamSubscription will be cancelled when widget is disposed
const Stream.empty().listen((event) {}).disposed(scope);
const Stream.empty().listen((event) {}).disposedBy(scope);
// Timer will be cancelled when widget is disposed
Timer(Duration.zero, () {}).disposed(scope);
Timer(Duration.zero, () {}).disposedBy(scope);
}
@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/animation.dart';

extension AnimationEagerListenerMixinDisposed on AnimationEagerListenerMixin {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/painting.dart';

extension BoxPainterDisposed on BoxPainter {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/foundation.dart';

extension ChangeNotifierDisposed on ChangeNotifier {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/painting.dart';

extension DecorationImagePainterDisposed on DecorationImagePainter {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/widgets.dart';

extension DisposableBuildContextDisposed on DisposableBuildContext {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/gestures.dart';

extension GestureRecognizerDisposed on GestureRecognizer {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/painting.dart';

extension ImageInfoDisposed on ImageInfo {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/painting.dart';

extension ImageStreamCompleterHandleDisposed on ImageStreamCompleterHandle {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/services.dart';

extension RestorationBucketDisposed on RestorationBucket {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/widgets.dart';

extension ScrollActivityDisposed on ScrollActivity {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/widgets.dart';

extension ScrollDragControllerDisposed on ScrollDragController {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/rendering.dart';

extension SemanticsHandleDisposed on SemanticsHandle {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/widgets.dart';

extension StateDisposed<T extends StatefulWidget> on State<T> {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
// ignore: invalid_use_of_protected_member
scope.addDispose(() async => dispose());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dispose_scope/dispose_scope.dart';
import 'package:flutter/scheduler.dart';

extension TickerDisposed on Ticker {
void disposed(DisposeScope scope) {
void disposedBy(DisposeScope scope) {
scope.addDispose(() async => dispose());
}
}
4 changes: 2 additions & 2 deletions packages/flutter_dispose_scope/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_dispose_scope
description: Package supporting flutter types for dispose_scope.
version: 1.0.0
version: 2.0.0
repository: https://github.com/RobertOdrowaz/dispose-scope/tree/master/packages/flutter_dispose_scope
issue_tracker: https://github.com/RobertOdrowaz/dispose-scope/issues
homepage: https://github.com/RobertOdrowaz/dispose-scope
Expand All @@ -10,7 +10,7 @@ environment:
flutter: ">=2.0.0"

dependencies:
dispose_scope: ^1.0.0
dispose_scope: ^2.0.0
flutter:
sdk: flutter
meta: ^1.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {
test(
'adds Dispose to DisposeScope when disposed is called',
() async {
animationEagerListenerMixin.disposed(scope);
animationEagerListenerMixin.disposedBy(scope);

await scope.dispose();

Expand Down
Loading

0 comments on commit 564c358

Please sign in to comment.