From 3b65448cedc75415a8cfcd563a2af59f6d1a3470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Thu, 26 Jan 2023 12:11:13 +0100 Subject: [PATCH] Remove support for registerStore --- packages/data/src/redux-store/index.js | 5 +++ packages/data/src/test/privateAPIs.js | 46 +------------------------- 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/packages/data/src/redux-store/index.js b/packages/data/src/redux-store/index.js index e6dbe4db471f7a..cdbc5ec59468a9 100644 --- a/packages/data/src/redux-store/index.js +++ b/packages/data/src/redux-store/index.js @@ -151,6 +151,8 @@ export default function createReduxStore( key, options ) { registry, thunkArgs ); + // Expose the private registration functions on the store + // so they can be copied to a sub registry in registry.js. lock( store, privateRegistrationFunctions ); const resolversCache = createResolversCache(); @@ -271,6 +273,9 @@ export default function createReduxStore( key, options ) { }, }; + // Expose the private registration functions on the store + // descriptor. That's a natural choice since that's where the + // public actions and selectors are stored . lock( storeDescriptor, privateRegistrationFunctions ); return storeDescriptor; diff --git a/packages/data/src/test/privateAPIs.js b/packages/data/src/test/privateAPIs.js index de6be4d9c3a079..ea6eb53eda3c87 100644 --- a/packages/data/src/test/privateAPIs.js +++ b/packages/data/src/test/privateAPIs.js @@ -129,33 +129,6 @@ describe( 'Private data APIs', () => { expect( unlockedSelectors.getPublicPrice() ).toEqual( 1000 ); } ); - it( 'should support registerStore', () => { - const groceryStore = registry.registerStore( - storeName, - storeDescriptor - ); - unlock( groceryStore ).registerPrivateSelectors( { - getSecretDiscount, - } ); - - const privateSelectors = unlock( registry.select( storeName ) ); - expect( privateSelectors.getSecretDiscount() ).toEqual( 800 ); - } ); - - it( 'should support mixing createReduxStore and registerStore', () => { - createReduxStore( storeName, storeDescriptor ); - const groceryStore2 = registry.registerStore( - storeName, - storeDescriptor - ); - unlock( groceryStore2 ).registerPrivateSelectors( { - getSecretDiscount, - } ); - - const privateSelectors = unlock( registry.select( storeName ) ); - expect( privateSelectors.getSecretDiscount() ).toEqual( 800 ); - } ); - it( 'should support sub registries', () => { const groceryStore = registry.registerStore( storeName, @@ -276,25 +249,8 @@ describe( 'Private data APIs', () => { ).toEqual( 100 ); } ); - it( 'should support registerStore', () => { - const groceryStore = registry.registerStore( - storeName, - storeDescriptor - ); - unlock( groceryStore ).registerPrivateActions( { - setSecretDiscount, - } ); - const privateActions = unlock( registry.dispatch( storeName ) ); - privateActions.setSecretDiscount( 400 ); - expect( - registry.select( storeName ).getState().secretDiscount - ).toEqual( 400 ); - } ); it( 'should support sub registries', () => { - const groceryStore = registry.registerStore( - storeName, - storeDescriptor - ); + const groceryStore = createStore(); unlock( groceryStore ).registerPrivateSelectors( { getSecretDiscount, } );