Flattening operators and behaviors ideation #7429
Replies: 8 comments 18 replies
-
@benlesh I like the idea of naming it I'd consider:
|
Beta Was this translation helpful? Give feedback.
-
Personally, I like the general idea. I do wonder if the args shouldn't be reversed, so that:
I know options objects generally go last because they're, well, optional, but I think this might warrant an exception. |
Beta Was this translation helpful? Give feedback.
-
I'd like to propose an enhancement to the interface FlatMapConfig {
concurrency?: number;
behavior?: 'merge' | 'switch' | 'exhaust';
ordered?: boolean;
} This additional flatMap(fn, { concurrency: Infinity, ordered: true }); The |
Beta Was this translation helpful? Give feedback.
-
What about something that tells what is actually happening like whenFull :
wait | drop | ignore (merge | switch | exhaust ) and ordered would add exit
strategy. Just loud thinking.
W dniu śr., 17.01.2024 o 01:25 Ben Lesh ***@***.***>
napisał(a):
… Okay, I think the challenge here is how to effectively write this API that
it's self-explanatory *what* it's doing.
ordered is really ensuring that the values from each subscription are
concatenated or that their order is maintained relative to the the values
that were mapped into each subscription.
behavior (or strategy) is also probably too generic, because really it's
defining "what happens when you're already at your concurrency limit, and
you get a new value from the source?". merge, exhaust, and switch *only
really mean something to RxJS users* and not really to everyone else.
—
Reply to this email directly, view it on GitHub
<#7429 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFKBQQJWOWJ4RVXCG5TJG43YO4K7NAVCNFSM6AAAAABB5K6UGCVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DCNJQGYZDE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
One more though: what if instead of drop so standard switchMap we add
function that actually can decide which concurrent stream it should
replace? Cause drop probably would replace first concurrent stream but what
if someone would like to replace last one or mayby middle one?
W dniu śr., 17.01.2024 o 01:32 Krzysztof Brilla ***@***.***>
napisał(a):
… What about something that tells what is actually happening like whenFull :
wait | drop | ignore (merge | switch | exhaust ) and ordered would add exit
strategy. Just loud thinking.
W dniu śr., 17.01.2024 o 01:25 Ben Lesh ***@***.***>
napisał(a):
> Okay, I think the challenge here is how to effectively write this API
> that it's self-explanatory *what* it's doing.
>
> ordered is really ensuring that the values from each subscription are
> concatenated or that their order is maintained relative to the the values
> that were mapped into each subscription.
>
> behavior (or strategy) is also probably too generic, because really it's
> defining "what happens when you're already at your concurrency limit,
> and you get a new value from the source?". merge, exhaust, and switch *only
> really mean something to RxJS users* and not really to everyone else.
>
> —
> Reply to this email directly, view it on GitHub
> <#7429 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AFKBQQJWOWJ4RVXCG5TJG43YO4K7NAVCNFSM6AAAAABB5K6UGCVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DCNJQGYZDE>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
-
As the creator of a library that gratefully and shamelessly steals these concurrency operators and hides them behind a facade - 𝗥𝘅𝑓𝑥 - I have some well-aged opinions on these names. I'd be honored if you steal back any part of this for helping to clarify the naming in v8: The words I've used for the concurrency operator modes:
But a whole other interesting way to go, is to not use a single name for the mode, but instead to separately encode for the 3 variables that determine each mode:
This gets around the challenge of choosing the perfect name. Incidentally, there's another useful operator strategy it'd be nice to include. It was called |
Beta Was this translation helpful? Give feedback.
-
I love the general idea !! About my personal opinion: => What I love about this operator is:
=> After reading the comments, I'd go for:
=> About the
|
Beta Was this translation helpful? Give feedback.
-
'I would like this if 'switch' was default, because I've seen a need for it about 10x more frequently than the other operators. And I get that this would reduce the code in the RxJS library itself, but I'm wondering if I'm downloading the code for all of this behavior even if I only want to do a traditional |
Beta Was this translation helpful? Give feedback.
-
I have an experimental operator that basically "does it all" (merge, concat, switch, exhaust) with concurrency. I'm likely to implementing all of our current flattening operators (
mergeMap
,concatMap
,switchMap
,exhaustMap
) on top of this, because it's lighter-weight that having separateconcatMap
andswitchMap
implementations, as an example.It also means you could do
switchMap
with concurrency, which has been a request several times. (This would mean interrupting the "oldest" subscription when you hit the concurrency limit).API Idea
I think I'm going to pitch this with the native observable proposal as well, but basically the API I have right now is as follows:
Why
flatMap
?We're flattening. In a general sense. Also,
flatMap
on a native observable is basicallyconcatMap
. Making it configurable is interesting and powerful.Names
The biggest problem I have with this is honestly naming things. The concurrency aspect adds a wrinkle. Does
switch
still make sense? Orexhaust
? What aboutconcat
vsmerge
? I just don't know.I'm looking for ideas/proposals there.
Beta Was this translation helpful? Give feedback.
All reactions