Skip to content

Commit

Permalink
Update states
Browse files Browse the repository at this point in the history
  • Loading branch information
PlugFox committed Jul 27, 2023
1 parent 5c5a2db commit 708fc98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
24 changes: 15 additions & 9 deletions lib/src/model/subscription_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@ sealed class CentrifugeSubscriptionState

/// Unsubscribed
/// {@macro subscription_state}
factory CentrifugeSubscriptionState.unsubscribed() =
CentrifugeSubscriptionState$Unsubscribed;
factory CentrifugeSubscriptionState.unsubscribed({
DateTime? timestamp,
({fixnum.Int64 offset, String epoch})? since,
}) = CentrifugeSubscriptionState$Unsubscribed;

/// Subscribing
/// {@macro subscription_state}
factory CentrifugeSubscriptionState.subscribing() =
CentrifugeSubscriptionState$Subscribing;
factory CentrifugeSubscriptionState.subscribing({
DateTime? timestamp,
({fixnum.Int64 offset, String epoch})? since,
}) = CentrifugeSubscriptionState$Subscribing;

/// Subscribed
/// {@macro subscription_state}
factory CentrifugeSubscriptionState.subscribed() =
CentrifugeSubscriptionState$Subscribed;
factory CentrifugeSubscriptionState.subscribed({
DateTime? timestamp,
({fixnum.Int64 offset, String epoch})? since,
}) = CentrifugeSubscriptionState$Subscribed;
}

/// Unsubscribed state
Expand Down Expand Up @@ -62,7 +68,7 @@ final class CentrifugeSubscriptionState$Unsubscribed
unsubscribed(this);

@override
int get hashCode => 0;
int get hashCode => Object.hash(0, timestamp, since);

@override
bool operator ==(Object other) => identical(this, other);
Expand Down Expand Up @@ -98,7 +104,7 @@ final class CentrifugeSubscriptionState$Subscribing
subscribing(this);

@override
int get hashCode => 1;
int get hashCode => Object.hash(1, timestamp, since);

@override
bool operator ==(Object other) => identical(this, other);
Expand Down Expand Up @@ -134,7 +140,7 @@ final class CentrifugeSubscriptionState$Subscribed
subscribed(this);

@override
int get hashCode => 2;
int get hashCode => Object.hash(2, timestamp, since);

@override
bool operator ==(Object other) => identical(this, other);
Expand Down
5 changes: 3 additions & 2 deletions lib/src/subscription/client_subscription_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ abstract base class CentrifugeClientSubscriptionBase
@protected
@mustCallSuper
void _initSubscription() {
_state; // ignore: unnecessary_statements
// TODO(plugfox): subscribe on disconnections
}

Expand All @@ -78,8 +79,8 @@ abstract base class CentrifugeClientSubscriptionBase
/// {@nodoc}
@override
CentrifugeSubscriptionState get state => _state;
CentrifugeSubscriptionState _state =
CentrifugeSubscriptionState.unsubscribed();
late CentrifugeSubscriptionState _state =
CentrifugeSubscriptionState.unsubscribed(since: _config.since);

/// Stream of subscription states.
/// {@nodoc}
Expand Down

0 comments on commit 708fc98

Please sign in to comment.