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

Mark/data apis unstable #40028

Merged
merged 1 commit into from
Apr 4, 2022
Merged
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
4 changes: 2 additions & 2 deletions packages/data/src/components/use-select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function useSelect( mapSelect, deps ) {
const listeningStores = useRef( [] );
const wrapSelect = useCallback(
( callback ) =>
registry.__experimentalMarkListeningStores(
registry.__unstableMarkListeningStores(
() => callback( registry.select, registry ),
listeningStores
),
Expand Down Expand Up @@ -222,7 +222,7 @@ export default function useSelect( mapSelect, deps ) {
onChange();

const unsubscribers = listeningStores.current.map( ( storeName ) =>
registry.__experimentalSubscribeStore( storeName, onChange )
registry.__unstableSubscribeStore( storeName, onChange )
);

return () => {
Expand Down
20 changes: 10 additions & 10 deletions packages/data/src/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { createEmitter } from './utils/emitter';
export function createRegistry( storeConfigs = {}, parent = null ) {
const stores = {};
const emitter = createEmitter();
const __experimentalListeningStores = new Set();
const listeningStores = new Set();

/**
* Global listener called for each store's update.
Expand Down Expand Up @@ -87,7 +87,7 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
const storeName = isObject( storeNameOrDescriptor )
? storeNameOrDescriptor.name
: storeNameOrDescriptor;
__experimentalListeningStores.add( storeName );
listeningStores.add( storeName );
const store = stores[ storeName ];
if ( store ) {
return store.getSelectors();
Expand All @@ -96,10 +96,10 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
return parent && parent.select( storeName );
}

function __experimentalMarkListeningStores( callback, ref ) {
__experimentalListeningStores.clear();
function __unstableMarkListeningStores( callback, ref ) {
listeningStores.clear();
const result = callback.call( this );
ref.current = Array.from( __experimentalListeningStores );
ref.current = Array.from( listeningStores );
return result;
}

Expand All @@ -118,7 +118,7 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
const storeName = isObject( storeNameOrDescriptor )
? storeNameOrDescriptor.name
: storeNameOrDescriptor;
__experimentalListeningStores.add( storeName );
listeningStores.add( storeName );
const store = stores[ storeName ];
if ( store ) {
return store.getResolveSelectors();
Expand Down Expand Up @@ -245,7 +245,7 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
* @param {Function} handler The function subscribed to the store.
* @return {Function} A function to unsubscribe the handler.
*/
function __experimentalSubscribeStore( storeName, handler ) {
function __unstableSubscribeStore( storeName, handler ) {
if ( storeName in stores ) {
return stores[ storeName ].subscribe( handler );
}
Expand All @@ -258,7 +258,7 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
return subscribe( handler );
}

return parent.__experimentalSubscribeStore( storeName, handler );
return parent.__unstableSubscribeStore( storeName, handler );
}

function batch( callback ) {
Expand All @@ -281,8 +281,8 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
register,
registerGenericStore,
registerStore,
__experimentalMarkListeningStores,
__experimentalSubscribeStore,
__unstableMarkListeningStores,
__unstableSubscribeStore,
};

//
Expand Down
2 changes: 1 addition & 1 deletion packages/data/src/test/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ describe( 'createRegistry', () => {
const listener2 = jest.fn();
// useSelect subscribes to the stores differently,
// This test ensures batching works in this case as well.
const unsubscribe = registry.__experimentalSubscribeStore(
const unsubscribe = registry.__unstableSubscribeStore(
'myAwesomeReducer',
listener2
);
Expand Down