-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FlatMapStrategy.throttle
#713
Conversation
I'm still wondering if Any thoughts on this? |
This PR is ready to review, but requires write permission to move on ("Ready for review" button doesn't appear in my screen): |
Conflicts: CHANGELOG.md
maybe this should be called |
@leonid-s-usov This is not exactly "oldest", in the sense that it only drops upstream values when the inner producer is still active. If we have to coin an accurate term in Swift collection terms, it would be like |
I would propose to name this |
Co-Authored-By: Anders Ha <anders@andersha.com>
Renamed to |
This makes no sense to me at all. P1 completes before P2 has emitted any values, so P1 still active is not true. Also, since P1 completes before P2 has emitted any values, P2 should take precedence, so I would expect the output to be:
|
@@ -96,6 +97,21 @@ public struct FlattenStrategy { | |||
/// Any failure from the inner streams is propagated immediately to the flattened | |||
/// stream of values. | |||
public static let race = FlattenStrategy(kind: .race) | |||
|
|||
/// Forward only events from the "first inner stream" that sends an event if not exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "first inner stream" that sends an event if not exists.
What does that mean? If what "not exists" (doesn't exist) ?
/// first inner stream again. | ||
/// | ||
/// The flattened stream of values completes only when the stream of streams has completed, | ||
/// and first inner stream has completed if exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, don't understand if exists
here.
@@ -96,6 +97,21 @@ public struct FlattenStrategy { | |||
/// Any failure from the inner streams is propagated immediately to the flattened | |||
/// stream of values. | |||
public static let race = FlattenStrategy(kind: .race) | |||
|
|||
/// Forward only events from the "first inner stream" that sends an event if not exists. | |||
/// Other inner streams is disposed of until the first inner stream is completed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
streams is disposed of
streams are disposed of
This PR adds
FlatMapStrategy.first
that works as a lightweightReactiveSwift.Action
and is equivalent toRxSwift.flatMapFirst
.This PR is related to
FlatMapStrategy.race
#233 which works quite differently as follows:As we can see in
flatten(.first)
that onlyP2
is not handled due toP1
still active (first inner producer) butP3
is well handled, this new strategy works as a lightweightAction
:Please note that if returning producer of
exec
can emit error,inputSignal.flatMap(.first, exec)
will terminate butaction.values
will not.(But I think it's also possible to fully simulate
action.errors
as well, by usingmaterialize
/dematerialize
to pattern-match and keep the stream alive)Checklist