Skip to content
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

@wordpress/data: Export entire registry context #15445

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/data/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

### 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)
- 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))

### Enhancements

- Export the entire registry context (as `RegistryContext`) so consuming code can implement it using the `useContext` react hook ([#15445](https://github.com/WordPress/gutenberg/pull/15445))

## 4.3.0 (2019-03-06)

Expand Down
4 changes: 4 additions & 0 deletions packages/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ _Returns_

Undocumented declaration.

<a name="RegistryContext" href="#RegistryContext">#</a> **RegistryContext**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make sure this is documented? See also #15176, which proposes documentation for RegistryConsumer and RegistryProvider.


Undocumented declaration.

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

Undocumented declaration.
Expand Down
4 changes: 3 additions & 1 deletion packages/data/src/components/registry-provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { createContext } from '@wordpress/element';
*/
import defaultRegistry from '../../default-registry';

const { Consumer, Provider } = createContext( defaultRegistry );
export const RegistryContext = createContext( defaultRegistry );

const { Consumer, Provider } = RegistryContext;

export const RegistryConsumer = Consumer;

Expand Down
6 changes: 5 additions & 1 deletion packages/data/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import * as plugins from './plugins';
export { default as withSelect } from './components/with-select';
export { default as withDispatch } from './components/with-dispatch';
export { default as withRegistry } from './components/with-registry';
export { default as RegistryProvider, RegistryConsumer } from './components/registry-provider';
export {
default as RegistryProvider,
RegistryConsumer,
RegistryContext,
} from './components/registry-provider';
export { default as __experimentalAsyncModeProvider } from './components/async-mode-provider';
export { createRegistry } from './registry';
export { plugins };
Expand Down