diff --git a/packages/data/CHANGELOG.md b/packages/data/CHANGELOG.md index 34cfc2e0096e12..91362f4e1d5c4c 100644 --- a/packages/data/CHANGELOG.md +++ b/packages/data/CHANGELOG.md @@ -1,3 +1,10 @@ +## Master + +### Bug Fix + +- Restore functionality of action-generators returning a Promise. Clarify intent and behaviour for `wp.data.dispatch` behaviour. Dispatch actions now always + return a promise ([#14830](https://github.com/WordPress/gutenberg/pull/14830) + ## 4.3.0 (2019-03-06) ### Enhancements diff --git a/packages/data/README.md b/packages/data/README.md index c496d0ef6dbf0a..312bcc54ce2612 100644 --- a/packages/data/README.md +++ b/packages/data/README.md @@ -332,6 +332,9 @@ _Returns_ Given the name of a registered store, returns an object of the store's action creators. Calling an action creator will cause it to be dispatched, updating the state value accordingly. +Note: Action creators returned by the dispatch will return a promise when +they are called. + _Usage_ ```js diff --git a/packages/data/src/components/with-dispatch/test/index.js b/packages/data/src/components/with-dispatch/test/index.js index c7a6fe9ac034f5..98f225fad2c406 100644 --- a/packages/data/src/components/with-dispatch/test/index.js +++ b/packages/data/src/components/with-dispatch/test/index.js @@ -34,8 +34,13 @@ describe( 'withDispatch', () => { return { increment: () => { - const actionReturnedFromDispatch = _dispatch( 'counter' ).increment( count ); - expect( actionReturnedFromDispatch ).toBe( undefined ); + const actionReturnedFromDispatch = Promise.resolve( _dispatch( 'counter' ).increment( count ) ); + expect( actionReturnedFromDispatch ).resolves.toEqual( + { + type: 'increment', + count, + } + ); }, }; } )( ( props ) =>