Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Nov 10, 2020
1 parent 5e3cf08 commit 5c01015
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/core-data/src/locks/actions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* WordPress dependencies
*/
import { awaitPromise } from '@wordpress/data-controls';
import { __unstableAwaitPromise } from '@wordpress/data-controls';
import { controls } from '@wordpress/data';

export function* __unstableAcquireStoreLock( store, path, { exclusive } ) {
const promise = yield* __unstableEnqueueLockRequest( store, path, {
exclusive,
} );
yield* __unstableProcessPendingLockRequests();
return yield awaitPromise( promise );
return yield __unstableAwaitPromise( promise );
}

export function* __unstableEnqueueLockRequest( store, path, { exclusive } ) {
Expand Down
4 changes: 0 additions & 4 deletions packages/data-controls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ _Returns_

- `Object`: The control descriptor.

<a name="awaitPromise" href="#awaitPromise">#</a> **awaitPromise**

Undocumented declaration.

<a name="controls" href="#controls">#</a> **controls**

The default export is what you use to register the controls with your custom
Expand Down
21 changes: 20 additions & 1 deletion packages/data-controls/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,26 @@ export function dispatch( ...args ) {
return dataControls.dispatch( ...args );
}

export const awaitPromise = function ( promise ) {
/**
* Dispatches a control action for awaiting on a promise to be resolved.
*
* @param {Object} promise Promise to wait for.
*
* @example
* ```js
* import { __unstableAwaitPromise } from '@wordpress/data-controls';
*
* // Action generator using apiFetch
* export function* myAction() {
* const promise = getItemsAsync();
* const items = yield __unstableAwaitPromise( promise );
* // do something with the items.
* }
* ```
*
* @return {Object} The control descriptor.
*/
export const __unstableAwaitPromise = function ( promise ) {
return {
type: 'AWAIT_PROMISE',
promise,
Expand Down

0 comments on commit 5c01015

Please sign in to comment.