-
Notifications
You must be signed in to change notification settings - Fork 393
Closed
Milestone
Description
Early on, I made a decision that when a handler returned undefined, the previous promise value should be forwarded through to the next promise. That's convenient in some cases, as it allows reusing and writing handlers that have no return statement.
However, it means that it's easy to get into trouble when doing things like this:
when(somethingHappens, function(result) {
return result["thePropertyIReallyCareAbout"];
}).then(handleProperty);In cases like that, where the first handler legitimately needs to return undefined, and we want handleProperty to receive undefined, it will instead receive result, which is just plain wrong. Right now, the workaround is:
when(somethingHappens, function(result) {
return result["thePropertyIReallyCareAbout"] || null;
}).then(handleProperty);which is ok, but probably would cause someone a real headache trying to figure it out, and means that handleProperty receives null instead of undefined.
Metadata
Metadata
Assignees
Labels
No labels