-
Notifications
You must be signed in to change notification settings - Fork 90
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
Rename "error/complete" to "end" #185
Comments
I’m not a fan of having a variadic method like end; I’d much prefer 2 simpler methods to 1 variadic one. |
Why? |
@staltz I'm in the same boat as @ljharb on this one, I'd rather be explicit about I know for Node Streams, they had |
Are they? How would that be semantically different to |
Having separate functions, like |
@staltz's point about the confusion about |
@ljharb I think it's hard to compare with Promises, because |
Promises have I’m sensitive to the concern about naming; I’m only objecting to conflating two purposes under one name. Perhaps “.catch” is a better name than “.error” because it implies “once”? |
I'd expect most people to use |
Hello! Robert "wall of text" de Forest here... Two issues under discussion
My positionIssue 1: message name describes termination modeI agree with @ljharb that variadic methods can be a bad code smell. If the message consumer cares about whether there was an error or not they have to put a test in their handler of the termination message. This seems to go against the philosophy of Observables where everything is supposed to be a simple mapping from problem to solution. Also, treating two messages identically is trivially easy: weAreDone = (whoCares) -> cleanUpMyMess()
myObserver =
aborted: weAreDone
ended: weAreDone I also agree with @staltz's point about the the value of the symmetry of It's trivial to map the single message protocol to a multi-message protocol: separateErrorSignal = (observable) ->
begin: observable.begin
next: observable.next
end: (error) ->
if error
observable.error error
else
observable.end() Given how easy it is to map between the two answers, my motivation shifts Including data in the name of a message moves logic from the handler to the The Observer pattern is itself a specialization of the EventEmitter/Listener Issue 2: what do we call it/them?If we decide to have a distinct message for abnormal stream termination, it If we decide to have a single message for all termination modes, I strongly |
This is a minor cosmetic suggestion for the Observer interface. Combine
error
andcomplete
intoend
.end(e)
corresponds toerror(e)
andend()
corresponds tocomplete()
.Reasoning:
start
andend
explicitly "symmetric" names to contain the observable executionerror
for (impossible) multiple errors:error
multiple times. They interpret it as a sister tonext
, not as a sister tocomplete
. The correct interpretation is "termination due to failure" but people often interpret it as "notify about an error".e
forend(e)
works like Unix process exit codes, where the argument of least information (in Unix, zero) means termination with nothing bad.start
has 5 characters,next
4,end
3.Motivation for naming is normally cosmetic anyway, so this is not an exception.
The text was updated successfully, but these errors were encountered: