Skip to content

Commit

Permalink
Merge pull request #57 from LoveCommunity/refactor/states-first
Browse files Browse the repository at this point in the history
improve `states.first` implementation
  • Loading branch information
beeth0ven committed Jun 28, 2022
2 parents 0e25dc5 + 102abd4 commit b1afb95
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/src/observables/states/states_first.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import 'states.dart';

@internal
T statesFirst<T>(States<T> states) {
Value<T>? result;
Value<T>? first;
states.observe((state) {
if (result == null) {
result = Value(state);
if (first == null) {
first = Value(state);
}
})
.dispose();
if (result == null) {
if (first == null) {
throw LatestStateNotReplayError(states);
}
return result!.value;
return first!.value;
}

0 comments on commit b1afb95

Please sign in to comment.