-
Notifications
You must be signed in to change notification settings - Fork 159
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
feat: Add switchMap operator #1787
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5d9df89
feat: switchMap
MartinHH 209e7dc
chore: minor code review issues
MartinHH 7fd2ad9
chore: fix header check
MartinHH d72946b
chore: fix java formatting
MartinHH dfdacce
docs: fix operator docs
MartinHH e9d647d
docs: improve SwitchMap description
MartinHH 673e54f
chore: various review issues
MartinHH 72abaf8
docs: fix typo
MartinHH dbe2998
docs: fix another typo
MartinHH 90c8ea8
chore: more review changes
MartinHH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
docs/src/main/paradox/stream/operators/Source-or-Flow/switchMap.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# switchMap | ||
|
||
Transforms each input element into a `Source` of output elements that is then flattened into the output stream until a new input element is received. | ||
|
||
@ref[Nesting and flattening operators](../index.md#nesting-and-flattening-operators) | ||
|
||
## Signature | ||
|
||
@apidoc[Flow.switchMap](Flow) { scala="#switchMap[T,M](f:Out=%3Eorg.apache.pekko.stream.Graph[org.apache.pekko.stream.SourceShape[T],M]):FlowOps.this.Repr[T]" java="#switchMap(org.apache.pekko.japi.function.Function)" } | ||
|
||
## Description | ||
|
||
Transforms each input element into a `Source` of output elements that is then flattened into the output stream until a | ||
new input element is received at which point the current (now previous) substream is cancelled (which is why this | ||
operator is sometimes also called "flatMapLatest"). | ||
|
||
## Reactive Streams semantics | ||
|
||
@@@div { .callout } | ||
|
||
**emits** when the current substream has an element available | ||
|
||
**backpressures** never | ||
|
||
**completes** upstream completes and the current substream completes | ||
|
||
@@@ | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
and then the old stream is been cancelled.
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.
it would be good to be more explicit in the docs about the behaviour
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.
I was struggling to find the right trade of between brevety (after all, there is a one-line-limit enforced for this part here) and explicitness. I now added a little bit more to this line and even more in the desciption section below.
(I'd be very open for any specific wording suggestions if you feel the updated version is not clear enough.)