-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(BehaviorSubject, ReplaySubject): internally using Sentinel o…
…bject instead ValueWrapper (#631) * rm wrapper * rm wrapper * docs * docs
- Loading branch information
Showing
8 changed files
with
100 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'dart:collection'; | ||
|
||
/// Provides [mapNotNull] extension method on [Iterable]. | ||
extension MapNotNullIterableExtension<T> on Iterable<T> { | ||
/// The non-`null` results of calling [transform] on the elements of [this]. | ||
/// | ||
/// Returns a lazy iterable which calls [transform] | ||
/// on the elements of this iterable in iteration order, | ||
/// then emits only the non-`null` values. | ||
/// | ||
/// If [transform] throws, the iteration is terminated. | ||
Iterable<R> mapNotNull<R>(R? Function(T) transform) sync* { | ||
for (final e in this) { | ||
final v = transform(e); | ||
if (v != null) { | ||
yield v; | ||
} | ||
} | ||
} | ||
} | ||
|
||
/// Provides [removeFirstElements] extension method on [Queue]. | ||
extension RemoveFirstElementsQueueExtension<T> on Queue<T> { | ||
/// Removes the first [count] elements of this queue. | ||
void removeFirstElements(int count) { | ||
for (var i = 0; i < count; i++) { | ||
removeFirst(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class _Empty { | ||
const _Empty(); | ||
|
||
@override | ||
String toString() => '<<EMPTY>>'; | ||
} | ||
|
||
/// @internal | ||
/// Sentinel object used to represent a missing value (distinct from `null`). | ||
const Object? EMPTY = _Empty(); // ignore: constant_identifier_names | ||
|
||
/// @internal | ||
/// Returns `null` if [o] is [EMPTY], otherwise returns itself. | ||
T? unbox<T>(Object? o) => identical(o, EMPTY) ? null : o as T; | ||
|
||
/// @internal | ||
/// Returns `true` if [o] is not [EMPTY]. | ||
bool isNotEmpty(Object? o) => !identical(o, EMPTY); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.