Skip to content

Commit

Permalink
Update deprecated .stream usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyus committed Mar 2, 2024
1 parent 1efe617 commit 4ce61e9
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/state_beacon_core/lib/src/beacons/readable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ReadableBeacon<T> extends Producer<T> {

/// Returns a broadcast [Stream] that emits the current value
/// and all subsequent updates to the value of this beacon.
/// Alias for [toStream(synchronous: false)]
@Deprecated('Use toStream() instead')
Stream<T> get stream => toStream();

/// Returns a broadcast [Stream] that emits the current value
Expand Down
8 changes: 4 additions & 4 deletions packages/state_beacon_core/test/src/beacons/future_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void main() {
// BeaconScheduler.flush();

await expectLater(
stats.stream,
stats.toStream(),
emitsInOrder([
isA<AsyncLoading<String>>(),
isA<AsyncError<String>>(),
Expand Down Expand Up @@ -675,7 +675,7 @@ void main() {
num1.increment();

await expectLater(
derivedBeacon.stream,
derivedBeacon.toStream(),
emitsInOrder([
isA<AsyncLoading<int>>(),
AsyncData<int>(11),
Expand Down Expand Up @@ -856,7 +856,7 @@ void main() {
);

await expectLater(
f.stream,
f.toStream(),
emitsInOrder([
isA<AsyncLoading<List<int>>>(),
isA<AsyncData<List<int>>>(),
Expand Down Expand Up @@ -894,7 +894,7 @@ void main() {
);

await expectLater(
d.stream,
d.toStream(),
emitsInOrder([
<int>[],
[1, 2, 3],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void main() {
test('should return a stream', () async {
final a = Beacon.writable(1);

final stream = a.stream;
final stream = a.toStream();

var called = 0;

Expand Down Expand Up @@ -114,7 +114,7 @@ void main() {

test('should convert a beacon to a stream', () async {
final beacon = Beacon.writable(0);
final stream = beacon.stream;
final stream = beacon.toStream();

expect(stream, isA<Stream<int>>());

Expand All @@ -140,8 +140,8 @@ void main() {
test('should cache stream', () {
final beacon = Beacon.writable(0);

final stream1 = beacon.stream;
final stream2 = beacon.stream;
final stream1 = beacon.toStream();
final stream2 = beacon.toStream();

expect(stream1.hashCode, stream2.hashCode);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void main() {
);

await expectLater(
d.stream,
d.toStream(),
emitsInOrder([
<int>[],
[1, 2, 3],
Expand Down Expand Up @@ -370,7 +370,7 @@ void main() {

late final s = Beacon.streamRaw(() => stream, initialValue: 0);

expect(s.stream, emitsInOrder([0, 1, 2, 3]));
expect(s.toStream(), emitsInOrder([0, 1, 2, 3]));
});

test('should cancel subscription to old stream', () async {
Expand Down
4 changes: 2 additions & 2 deletions packages/state_beacon_core/test/src/beacons/stream_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main() {
final myBeacon = Beacon.stream(() => myStream);

expect(
myBeacon.stream,
myBeacon.toStream(),
emitsInOrder([
isA<AsyncLoading<int>>(),
isA<AsyncData<int>>(),
Expand All @@ -45,7 +45,7 @@ void main() {
final myBeacon = Beacon.stream(errorStream);

expect(
myBeacon.stream,
myBeacon.toStream(),
emitsInOrder(
[
isA<AsyncLoading<int>>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void main() {
test('should set the beacon supplied', () async {
final beacon = Beacon.writable<AsyncValue<int>>(AsyncData(0));

final beaconStream = beacon.stream;
final beaconStream = beacon.toStream();

expect(
beaconStream,
Expand Down Expand Up @@ -64,7 +64,7 @@ void main() {
test('should set optimistic result while loading', () async {
final beacon = Beacon.writable<AsyncValue<int>>(AsyncData(0));

final beaconStream = beacon.stream;
final beaconStream = beacon.toStream();

expect(
beaconStream,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ void main() {
final lazyTimestamp = group.lazyTimestamped<int>();
final undoRedo = group.undoRedo<int>(0);
final lazyUndoRedo = group.lazyUndoRedo<int>();
final stream = group.stream<int>(() => readable.stream);
final streamRaw = group.streamRaw<int?>(() => readable.stream);
final stream = group.stream<int>(readable.toStream);
final streamRaw = group.streamRaw<int?>(readable.toStream);
final future = group.future<int>(() async => 1);
final list = group.list<int>([0]);
final hashSet = group.hashSet<int>({0});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ void main() {
final stream = Stream.periodic(k1ms, (i) => i).take(5);
final beacon = stream.toRawBeacon(isLazy: true).map((v) => v * 10);

await expectLater(beacon.stream, emitsInOrder([0, 10, 20, 30, 40]));
await expectLater(beacon.toStream(), emitsInOrder([0, 10, 20, 30, 40]));
});

test('should transform input values when use mid-chain', () async {
Expand All @@ -606,7 +606,7 @@ void main() {
.map((v) => v + 1)
.filter((_, n) => n.isEven);

await expectLater(beacon.stream, emitsInOrder([1, 2, 4]));
await expectLater(beacon.toStream(), emitsInOrder([1, 2, 4]));
});

test('should transform input values when use mid-chain/2', () async {
Expand All @@ -617,7 +617,7 @@ void main() {
.map((v) => v + 1)
.throttle(duration: k1ms);

await expectLater(beacon.stream, emitsInOrder([1, 3, 5]));
await expectLater(beacon.toStream(), emitsInOrder([1, 3, 5]));

await delay();

Expand Down Expand Up @@ -714,7 +714,7 @@ void main() {
.map((v) => v + 1)
.filter((_, n) => n.isEven);

await expectLater(beacon.stream, emitsInOrder([1, 2, 4]));
await expectLater(beacon.toStream(), emitsInOrder([1, 2, 4]));

beacon.set(10);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void main() {
final beacon = Beacon.writable<AsyncValue<int>>(AsyncData(0));

expect(
beacon.stream,
beacon.toStream(),
emitsInOrder(
[
AsyncData(0),
Expand Down

0 comments on commit 4ce61e9

Please sign in to comment.