How does the combiner actually work?
Stream<bool> get isValid => Rx.combineLatest2(name1, mobile1, (name2, mobile2) => true);
If name1
and mobile1
are streams, then what are the types of name2
and mobile2
in brackets?
How does the combiner actually work?
Stream<bool> get isValid => Rx.combineLatest2(name1, mobile1, (name2, mobile2) => true);
If name1
and mobile1
are streams, then what are the types of name2
and mobile2
in brackets?
Copyright © 2021 Jogjafile Inc.
In your example,
name2
andmobile2
refer to the latest content that was emitted by the streamsname1
andmobile1
. So your question - the types ofname2
andmobile2
- depend on the streams that you give it.I think calling them
name1
andname2
actually kind of makes it a bit confusing, and perhaps it would make more sense to think of it like this:To give a concrete example, imagine that
name
is aString
andmobile
isint
. And imagine that what you want is a Stream of your own class calledPerson
which has the parametername
andmobile
like this:You could combine your latest
name
and latestmobile
to get aStream<Person>
like this:where:
nameStream
is of typeStream<String>
mobileStream
is of typeStream<int>
name
is of typeString
mobile
is of typeint
person
returnsStream<Person>
You can specify your class types in the function like this: