Skip to content

Conversation

benarmston
Copy link

Previously, if an action had both meta data and payload, the metadata would be clobbered with the payload once the promise had either been rejected or resolved.

Now, the original payload is added to the metadata under the key payload preserving any meta already present; unless there was meta under the key payload which seems unlikely.

This is a breaking API change.

This change makes it possible for client code to distinguish between rejected
and failed promises when attaching then, or catch handlers.  With the previous
behaviour it was impossible to make this distinction (at least using the
promise API).

If the old behaviour is desired, a client can add a catch handler which
returns the error before dispatching:

```
dispatch(myPromise.catch((err) => err))
```
 - Add returns to expectations including eventually.  Apparently, this is
   required for the test framework to properly test the expectation. See the
   first section of http://chaijs.com/plugins/chai-as-promised.

 - Catch exception thrown now that we're using await with a rejected promise.
Previously, if an action had both meta data and payload, the metadata would be
clobbered with the payload once the promise had either been rejected or
resolved.

Now, the original payload is added to the metadata under the key `payload`
preserving any meta already present; unless there was meta under the key
`payload` which seems unlikely.

This is a breaking API change.
@alanrubin
Copy link
Owner

Good catch @benarmston ! And thanks for the PR. I'm still not sure that putting the payload as a property of the meta is the best way to go, I will give a thought today and get back today so we can decide together. Together with that I see the #2 issue commits are including in this PR... I guess that is not how it was supposed to be, isn't it ?

@benarmston
Copy link
Author

You're quite right about the commits from #2. I can amend this PR when we have a decision on where the payload should go. For what it's worth, I currently have no need to have the original payload available; just a need to have the meta not be clobbered.

@benarmston
Copy link
Author

Hi @alanrubin did you find time to think about your preferred location for the payload?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants