Comments (3)
This could be handled by emitting a materialized signal and inspecting the results. But, I think it might also be worth considering aligning the default behavior for this with ReactiveX if possible.
It's quite common to chain async calls using flatMap
, where it's expected that any failures are propagated downstream.
For example, with something like this:
_ = requestEpisode(id: epID)
.flatMap { requestSeason(id: $0.seasonID) }
.flatMap { requestSeries(id: $0.seriesID) }
Assuming that any of the requests could fail with an HTTPError
, the final error varies depending on which request fails:
- if the source signal (
requestEpisode
) failed, it would be anHTTPError
- if either of the chained inner signals (
requestSeason
,requestSeries
) failed, it would send the originalSignalError.closed
error fromrequestEpisode
, implying success
With respect to the design difference, I find it's still similar to ReactiveSwift's idea of a "terminating event", which is either .completed
, .failed
, or .interrupted
. For flatMap
, .completed
events are not forwarded from inner signals, but .failed
events are. A .failed
event also stops all further events from other inner signals.
I wonder if CwlSignal might want to consider some of the SignalError
cases to be special errors that aren't forwarded, but continue to forward others (ie. the "true failures")?
from cwlsignal.
Hi Steve,
The behavior in CwlSignal on this issue is intentional but whether it represents an appropriate implementation of flatMap
is a different thing.
Specifically, the transformFlatten
function (CwlSignalExtensions.swift, line 109) handles this behavior. You can see that it deliberately grabs the closeError
from the source signal and when all child signals plus the source are finally closed, the closeError
is emitted on the output.
In your test case, you're seeing the successful SignalError.close
sent by the fromSequence
operator, rather than the child TestError.oneValue
.
There's a design difference between typical ReactiveX and CwlSignal here: CwlSignal propagates just 1 error per signal (the first error is always the end of signal), so it can't propagate errors for each of the child signals unless it "materializes" them (wraps in an additional Result
wrapper so the values and errors of the child all constitute "values" in the output).
Perhaps CwlSignal should have an additional implementation of flatMap that emits a materialized signal to handle this difference?
from cwlsignal.
I believe I've addressed this issue now (since CwlSignal 2.0.0-beta.10).
The old behavior β inner signals either never close the outer signal or always close the outer signal β is replaced with a new behavior that allows non-successful inner signal close conditions to propagate and close the outer signal while allowing the outer signal to continue after successful inner closes.
Specifically, the boolean closePropagation
is replaced with SignalClosePropagation
, an enum. This enum supports three modes: none
, all
(corresponding to the old values of the bool
) and the new error
. This error
is now used in all Reactive
implementations for nested signals.
from cwlsignal.
Related Issues (20)
- CFBundleVersion is blank⦠HOT 1
- Library not loaded: @rpath/CwlUtils.framework/CwlUtils HOT 1
- Installation through Carthage fails citing Bitcode issues HOT 6
- How can I ignore previous values sent by a signal? HOT 2
- frameworks trigger warning about not being safe in an extension HOT 1
- Command CodeSign failed with a nonzero exit code HOT 1
- Executing test target fails because of development team id HOT 4
- Undeclared type 'Cancellable'? HOT 3
- Playground errors - commit 73258ba ( Nov. 26, 2017 ) HOT 2
- Provide benchmark code HOT 5
- Add support for key paths? HOT 2
- [Xcode 10 beta 4] Possibly there are two concurrent builds running in the same filesystem location HOT 4
- CwlUtils.framework is missing in Products HOT 2
- Archiving produces invalid package HOT 3
- Deadlock HOT 2
- Lastest commits in CwlUtils are breaking CwlSignal current version HOT 3
- Please support swift version 5.0
- Signal reactivation fails HOT 1
- iOS Version Issue
- Unable to update my source code with Xcode 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cwlsignal.