Skip to content

Commit ed7b27c

Browse files
authored
refactor(bloc)!: introduce EmittableStateStreamableSource (#4311)
1 parent faada70 commit ed7b27c

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

.github/actions/dart_package/action.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ inputs:
55
codecov_token:
66
required: true
77
description: The Codecov token used to upload coverage
8+
collect_coverage:
9+
required: false
10+
default: "true"
11+
description: Whether to collect code coverage
12+
collect_score:
13+
required: false
14+
default: "true"
15+
description: Whether to collect the pana score
816
concurrency:
917
required: false
1018
default: "4"
@@ -69,13 +77,15 @@ runs:
6977
dart test -j ${{inputs.concurrency}} --coverage=coverage && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=${{inputs.report_on}} --check-ignore
7078
7179
- name: 📦 Detect Package Name
80+
if: inputs.collect_coverage == 'true'
7281
env:
7382
PACKAGE_PATH: ${{ inputs.working_directory}}
7483
id: package
7584
shell: ${{ inputs.shell }}
7685
run: echo "name=${PACKAGE_PATH##*/}" >> $GITHUB_OUTPUT
7786

7887
- name: ⬆️ Upload Coverage
88+
if: inputs.collect_coverage == 'true'
7989
uses: codecov/codecov-action@v4
8090
env:
8191
PACKAGE_PATH: ${{ inputs.working_directory}}
@@ -84,13 +94,15 @@ runs:
8494
token: ${{ inputs.codecov_token }}
8595

8696
- name: 📊 Verify Coverage
97+
if: inputs.collect_coverage == 'true'
8798
uses: VeryGoodOpenSource/very_good_coverage@v3
8899
with:
89100
path: ${{inputs.working_directory}}/coverage/lcov.info
90101
exclude: ${{inputs.coverage_excludes}}
91102
min_coverage: ${{inputs.min_coverage}}
92103

93104
- name: 💯 Verify Pub Score
105+
if: inputs.collect_score == 'true'
94106
working-directory: ${{ inputs.working_directory }}
95107
shell: ${{ inputs.shell }}
96108
run: |

.github/workflows/main.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ jobs:
214214
codecov_token: ${{ secrets.CODECOV_TOKEN }}
215215
working_directory: packages/${{ matrix.package }}
216216
min_coverage: 100
217+
# TODO: remove once bloc v9 is published
218+
# https://github.com/dart-lang/pana/issues/1254
219+
collect_score: false
217220

218221
flutter_package_checks:
219222
needs: changes
@@ -238,6 +241,9 @@ jobs:
238241
codecov_token: ${{ secrets.CODECOV_TOKEN }}
239242
working_directory: packages/${{ matrix.package }}
240243
min_coverage: 100
244+
# TODO: remove once bloc v9 is published
245+
# https://github.com/dart-lang/pana/issues/1254
246+
collect_score: false
241247

242248
angular_dart_example_checks:
243249
needs: changes

packages/bloc/lib/src/bloc_base.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ abstract class ErrorSink implements Closable {
4545
void addError(Object error, [StackTrace? stackTrace]);
4646
}
4747

48+
/// A [StateStreamableSource] that can emit new states.
49+
abstract class EmittableStateStreamableSource<State>
50+
implements StateStreamableSource<State>, Emittable<State> {}
51+
4852
/// {@template bloc_base}
4953
/// An interface for the core functionality implemented by
5054
/// both [Bloc] and [Cubit].
5155
/// {@endtemplate}
5256
abstract class BlocBase<State>
53-
implements StateStreamableSource<State>, Emittable<State>, ErrorSink {
57+
implements EmittableStateStreamableSource<State>, ErrorSink {
5458
/// {@macro bloc_base}
5559
BlocBase(this._state) {
5660
// ignore: invalid_use_of_protected_member

packages/bloc_test/lib/src/bloc_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ import 'package:test/test.dart' as test;
136136
///
137137
/// [configuring tags]: https://github.com/dart-lang/test/blob/master/pkgs/test/doc/configuration.md#configuring-tags
138138
@isTest
139-
void blocTest<B extends BlocBase<State>, State>(
139+
void blocTest<B extends EmittableStateStreamableSource<State>, State>(
140140
String description, {
141141
required B Function() build,
142142
FutureOr<void> Function()? setUp,
@@ -173,7 +173,7 @@ void blocTest<B extends BlocBase<State>, State>(
173173
/// Internal [blocTest] runner which is only visible for testing.
174174
/// This should never be used directly -- please use [blocTest] instead.
175175
@visibleForTesting
176-
Future<void> testBloc<B extends BlocBase<State>, State>({
176+
Future<void> testBloc<B extends EmittableStateStreamableSource<State>, State>({
177177
required B Function() build,
178178
FutureOr<void> Function()? setUp,
179179
State Function()? seed,

packages/bloc_test/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ topics: [bloc, state-management, test]
99
funding: [https://github.com/sponsors/felangel]
1010

1111
environment:
12-
sdk: ">=2.12.0 <4.0.0"
12+
sdk: ">=2.14.0 <4.0.0"
1313

1414
dependencies:
1515
bloc: ^8.1.1
1616
diff_match_patch: ^0.4.1
1717
meta: ^1.3.0
18-
mocktail: ">=0.2.0 <2.0.0"
18+
mocktail: ^1.0.0
1919
test: ^1.16.0
2020

2121
dev_dependencies:
22-
rxdart: ^0.27.2
22+
rxdart: ^0.28.0
2323

2424
screenshots:
2525
- description: The bloc test package logo.

0 commit comments

Comments
 (0)