Last active
December 7, 2022 18:53
-
-
Save alexcmgit/17e2720be36c2bbde3da7d5a6381776d to your computer and use it in GitHub Desktop.
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
void main() { | |
// Simulate the [signinResponse] as a simply [String]. | |
Stream<String> signInStream() => Stream<String>.periodic(Duration(seconds: 1), (computation) => 'Login $computation'); | |
// Simulate the [userResponse] as a simply [int]. | |
Stream<int> getUserDetailsStream() => Stream<int>.periodic(Duration(seconds: 1)); | |
final Stream<Stream<int>> itIsWhatYouAreDoing = signInStream().asyncMap((event) => getUserDetailsStream()); | |
// What you are saying you want to achieve: | |
final Stream<int> userDetailsStream = signInStream().asyncMap((event) async => await getUserDetailsStream().first); | |
print(itIsWhatYouAreDoing); // Stream<Stream<int>> | |
print(userDetailsStream); // Stream<int> | |
// But this has some cons: you lose any other post-event emitted by all [getUserDetailsStream] Streams. | |
// You didn't provide any detail about this, so I'll assuming they are irrelevant?!? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment