Closed stephencelis closed 5 years ago
Thanks about the first one - regarding the second one, I guess we could add it, even though it's more like comparing
ifEmpty(default: observable)
.switchLatest()
in RxSwift - it's not really a 1v1 operator comparison. What do you think?
Ok I resolved both in 3f18df3
I think it's useful to show solutions even if they're more verbose. Could use a ⚠️ to distinguish operators that aren't 1:1 mappings. Same as "flatMapLatest" which isn't really "switchToLatest" since there's no transform. You're stuck with something like "map { … return publisher }.switchToLatest()".
I've added it in the note instead as a direct mapping - felt better to me. The warning sign thing is also interesting, I'll give it some though :) Thank you!
Could also add a note that startWith(value)
is merge(with: Publishers.Just(value))
And no prob! Thanks for making this resource! Think it'll help a lot of folks.
I'm worried about adding all these composition hacks but I guess if we want to provide a good bridge, it should be there.
It would be the same as using prepend
with a Just
in Combine, but that's more comparable to Observable.concat(.just("value"), stream)
then startWith
. Not too sure on where to put the line :)
Oh neat! Haven't explored enough to see prepend
yet. Looks like prepend
can be used the same way startWith
is used, no? So could be considered a direct map.
Actually seems to be :) I hadn't noticed before but prepend has one overaload that takes a variadic array, and one that takes a different stream (like concat).
Combine's "replaceEmpty(with:)" appears to be "ifEmpty(default:)", but the sheet has them reversed.
Combine seems to have no operator fo "ifEmpty(switchTo:)", though it can be achieved with "replaceEmpty(with: publisher).switchToLatest()"