Skip to content

Commit

Permalink
Remove support for registerStore
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Jan 26, 2023
1 parent 8067b46 commit 3b65448
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 45 deletions.
5 changes: 5 additions & 0 deletions packages/data/src/redux-store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down
46 changes: 1 addition & 45 deletions packages/data/src/test/privateAPIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
} );
Expand Down

0 comments on commit 3b65448

Please sign in to comment.