-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Transforming and Combining operators for PrimitiveSequence #1248
Comments
Hi @hagmas , I agree with most of what you've said. We need to continue improving primitive sequence derived traits. I'm not that concerned at the moment that I understand that RxJava defines all of the operators for each unit completely separate and optimized, but since we didn't notice any performance issues my biggest concern is to make the project as small and maintainable as possible. I also seemed to me that it would be cool to just present how all of these concepts can be built on top of observable sequence APIs :) I think we need to tackle one item at a time. I would rather first fill out the missing functionalities and leave removal and polishing of redundant ones for next major update. They aren't perfect, but they also don't do much harm. If you are willing to help with those items, feel free to suggest what to tackle first. If we start working on all of those things in that list at once, we will make one giant mess that will be hard to CR. Maybe temporarily adding Then adding Then adding etc ... |
Hello @kzaher , Thank you for replying. What you said sounds like a plan. After I looked back all the operators, probably |
This should be solved now. |
Short description of the issue:
Some transforming and combining operators needs to be added to PrimitiveSequence, and some should be removed because they have no effects on some traits, such as
FlatMap
andMap
for Completable.Related Issues:
#1206
#1245
Expected outcome:
Here is a table that describes the relationship between some operators and PrimitiveSequence traits. ⭕️ means the operator has effect on the trait and ❌ means ineffective.
AsMaybe
AsSingle
AsCompletable
Combine
Zip
)Zip
)Zip
)Concat
Map
Merge
Switch
,FlatMap
SwitchIfEmpty
Concat
)Zip
*1:
Concat
forMaybe
is effective only when either of the observables is completed.*2:
Zip
forCompletable
is effective but a useless resultSelector needs to be defined. This can be replaced withMerge
operator.To implement these new transforming and combining operators for PrimitiveSequence, I would suggest to define them separately in three files "Single+Operators", "Maybe+Operators" and "Completable+Operators", e.g., defining
FlatMap
operator in "Single+Operators" and "Maybe+Operators", but not in "Completable+Operators". Operators valid for all the traits such asCombine
or other creating/utility operators can be defined in the "PrimitiveSequence.swift" file as currently defined.What actually happens:
The actual issue with the current version of code is that,
Map
andFlatMap
can be used forCompletable
because they are defined in the extension of PrimitiveSequence. However, actually they have no effect and can be misleading.RxJava defines all the operators separately for all the traits and avoids this kind of situation.
Also, some combining and transforming operators should be added for usability because to use some operators we need to convert PrimitiveSequence to observable once which increase redundancy in the code.
RxSwift/RxCocoa/RxBlocking/RxTest version/commit
3.4.1
Platform/Environment
How easy is to reproduce? (chances of successful reproduce after running the self contained code)
Xcode version:
The text was updated successfully, but these errors were encountered: