Last active
November 11, 2022 03:25
-
-
Save heyhey1028/dfad34a15198cddb76ed36b6bf4c0119 to your computer and use it in GitHub Desktop.
Extensions for Flutter Projects
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
extension StreamEx<T> on Stream<T> { | |
Stream<T> onlyNotify( | |
bool Function(T? previousEvent, T currentEvent) test, | |
) async* { | |
T? previousEvent; | |
await for (final event in this) { | |
if (test(previousEvent, event)) { | |
yield event; | |
} | |
previousEvent = event; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment