Skip to content

Commit

Permalink
add class modifiers (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoc081098 authored Sep 2, 2024
1 parent bddbfe6 commit 3d6f6c8
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import 'value_subject.dart';
/// a broadcast [Stream], and provides synchronous access to the latest emitted value.
///
/// See [NotReplayValueStream].
class NotReplayValueConnectableStream<T> extends AbstractConnectableStream<T,
ValueSubject<T>, NotReplayValueStream<T>>
final class NotReplayValueConnectableStream<T>
extends AbstractConnectableStream<T, ValueSubject<T>,
NotReplayValueStream<T>>
with NotReplayValueStreamMixin<T>
implements NotReplayValueStream<T> {
final ValueSubject<T> _subject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import 'package:rxdart/rxdart.dart' show ValueStream;
/// The marker interface for [ValueStream] classes
/// that provide synchronous access to the last emitted item,
/// but do not replay the latest value.
abstract class NotReplayValueStream<T> extends ValueStream<T> {}
abstract interface class NotReplayValueStream<T> implements ValueStream<T> {}
2 changes: 1 addition & 1 deletion lib/src/not_replay_value_stream/stream_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:rxdart/rxdart.dart' show ErrorAndStackTrace;

/// Class that holds latest value and lasted error emitted from Stream.
@internal
class StreamEvent<T> {
final class StreamEvent<T> {
T _value;
ErrorAndStackTrace? _errorAndStacktrace;
var _lastEventIsData = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'stream_event.dart';
/// it has subscribers or not, as well as getting a callback when either of
/// these change.
@sealed
class ValueStreamController<T> implements StreamController<T> {
final class ValueStreamController<T> implements StreamController<T> {
final StreamController<T> _delegate;
final StreamEvent<T> _dataOrError;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/not_replay_value_stream/value_subject.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import 'stream_event.dart';
/// subject.add(2);
/// subject.close();
@sealed
class ValueSubject<T> extends Subject<T>
final class ValueSubject<T> extends Subject<T>
with NotReplayValueStreamMixin<T>
implements NotReplayValueStream<T> {
final StreamEvent<T> _dataOrError;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/operators/done_on_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';

import '../utils/default_sink.dart';

class _DoneOnErrorSink<T> extends BaseEventSink<T, T> {
final class _DoneOnErrorSink<T> extends BaseEventSink<T, T> {
final bool Function(Object e, StackTrace s) predicate;

_DoneOnErrorSink(super.sink, this.predicate);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/operators/ignore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';

import '../utils/default_sink.dart';

class _IgnoreErrorsEventSink<T> extends BaseEventSink<T, T> {
final class _IgnoreErrorsEventSink<T> extends BaseEventSink<T, T> {
_IgnoreErrorsEventSink(super.sink);

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/src/operators/void.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';

import '../utils/default_sink.dart';

class _AsVoidStreamSink<T> extends BaseEventSink<T, void> {
final class _AsVoidStreamSink<T> extends BaseEventSink<T, void> {
_AsVoidStreamSink(super.sink);

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/src/single/on_error_resume.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:async';
import '../utils/default_sink.dart';
import 'single.dart';

class _OnErrorReturnSingleSink<T> extends BaseEventSink<T, T> {
final class _OnErrorReturnSingleSink<T> extends BaseEventSink<T, T> {
final T returnValue;

_OnErrorReturnSingleSink(super.sink, this.returnValue);
Expand All @@ -16,7 +16,7 @@ class _OnErrorReturnSingleSink<T> extends BaseEventSink<T, T> {
sink.add(returnValue);
}

class _OnErrorReturnWithSingleSink<T> extends BaseEventSink<T, T> {
final class _OnErrorReturnWithSingleSink<T> extends BaseEventSink<T, T> {
final T Function(Object error, StackTrace stackTrace) itemSupplier;

_OnErrorReturnWithSingleSink(super.sink, this.itemSupplier);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/single/single.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'internal.dart';
/// error done
/// ```
@sealed
class Single<T> extends StreamView<T> {
final class Single<T> extends StreamView<T> {
/// Underline source Stream.
final Stream<T> _stream;

Expand Down Expand Up @@ -179,7 +179,7 @@ class Single<T> extends StreamView<T> {
Single.safe(_stream.asyncMap(convert));
}

class _SingleOrErrorStreamSink<T> extends BaseEventSink<T, T> {
final class _SingleOrErrorStreamSink<T> extends BaseEventSink<T, T> {
var value = _null;
ErrorAndStackTrace? error;

Expand Down
4 changes: 2 additions & 2 deletions lib/src/state_stream/state_connectable_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'state_subject.dart';
///
/// This is a combination of [ConnectableStream], [ValueStream], [ValueSubject] and [Stream.distinct].
@sealed
abstract class StateConnectableStream<T> extends ConnectableStream<T>
sealed class StateConnectableStream<T> extends ConnectableStream<T>
implements StateStream<T> {
/// Constructs a [Stream] which only begins emitting events when
/// the [connect] method is called, this [Stream] acts like a
Expand Down Expand Up @@ -44,7 +44,7 @@ abstract class StateConnectableStream<T> extends ConnectableStream<T>
StateStream<T> refCount();
}

class _StateConnectableStream<T>
final class _StateConnectableStream<T>
extends AbstractConnectableStream<T, StateSubject<T>, StateStream<T>>
with StateStreamMixin<T>
implements StateConnectableStream<T> {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/state_stream/state_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export '../utils/equality.dart';
///
/// This [Stream] do **not replay** the latest value, see [NotReplayValueStream].
/// This [Stream] always has **no error**.
abstract class StateStream<T> extends NotReplayValueStream<T> {
abstract interface class StateStream<T> implements NotReplayValueStream<T> {
/// Determined equality between previous data event and current data event.
Equality<T> get equals;

Expand Down Expand Up @@ -56,7 +56,7 @@ abstract class StateStream<T> extends NotReplayValueStream<T> {
}

/// A mutable [StateStream] that provides a setter for [value].
abstract class MutableStateStream<T> implements StateStream<T> {
abstract interface class MutableStateStream<T> implements StateStream<T> {
/// Set the [value] of this [MutableStateStream].
/// Also emits the [newValue] to all listeners
/// if it is not equal to the current value.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/state_stream/state_subject.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import 'state_stream_mixin.dart';
/// subject.add(3);
/// subject.close();
@sealed
class StateSubject<T> extends Subject<T>
final class StateSubject<T> extends Subject<T>
with StateStreamMixin<T>
implements StateStream<T>, MutableStateStream<T> {
T _value;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/default_sink.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mixin ForwardingSinkMixin<T, R> implements ForwardingSink<T, R> {
}

/// This [EventSink] class implements all [EventSink] members except [add].
abstract class BaseEventSink<T, R> implements EventSink<T> {
abstract base class BaseEventSink<T, R> implements EventSink<T> {
/// The output sink.
@protected
final EventSink<R> sink;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/stream_sink_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:meta/meta.dart';

/// A class that exposes only the [StreamSink] interface of an object.
@internal
class StreamSinkWrapper<T> implements StreamSink<T> {
final class StreamSinkWrapper<T> implements StreamSink<T> {
final StreamSink<T> _target;

/// Creates a [StreamSinkWrapper] that wraps [target].
Expand Down

0 comments on commit 3d6f6c8

Please sign in to comment.