Created
January 29, 2021 06:22
-
-
Save hacker1024/6c39eee309566e8d4771fbf39678ae6c to your computer and use it in GitHub Desktop.
A Dart extension function to convert a regular Stream into an RxDart ReplayStream.
This file contains hidden or 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
import 'package:rxdart/streams.dart'; | |
import 'package:rxdart/subjects.dart'; | |
extension StreamUtils<T> on Stream<T> { | |
ReplayStream<T> replay() { | |
final subject = ReplaySubject<T>(); | |
pipe(subject); | |
return subject; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment