Skip to content

Using a stream viewmodel with stream that requires arguments #1054

Answered by FilledStacks
zuboje asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @zuboje good question, I can see you've been going deep in Stacked if you have a question like this 😄

To solve this you simply change the Stream in the ViewModel, then rebuild it.

So we have a function called notifySourceChanged that can be called when a source has changed. What this will allow you to do is start change the stream to a new stream with the same data type dynamically.

So in your case, you would start the ViewModel with an Empty Stream, that does nothing.

When you have the data you need to create the Stream you want, you can set that to the source, and then call notifySourceChanged. Here's a small example, I'll comment on it.

  late Stream<int> _currentSource; // <== The …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@FilledStacks
Comment options

@zuboje
Comment options

Answer selected by zuboje
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants