Skip to content

Commit dee2345

Browse files
phryneasmsutkowski
andauthored
rename createPureApi to createBaseApi (#137)
* rename createPureApi to createBaseApi Co-authored-by: Matt Sutkowski <[email protected]>
1 parent 425913a commit dee2345

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

docs/concepts/customizing-create-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ hide_title: true
99

1010
Currently, RTK Query includes two variants of `createApi`:
1111

12-
- `createPureApi` which contains only the basic redux logic (the core module)
12+
- `createBaseApi` which contains only the basic redux logic (the core module)
1313
- `createApi` which contains both the core and react-hooks modules
1414

1515
You can create your own versions of `createApi` by either specifying non-default options for the modules or by adding your own modules.

examples/svelte/src/services/counter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createApi, fetchBaseQuery, retry } from '@rtk-incubator/rtk-query';
1+
import { createBaseApi, fetchBaseQuery, retry } from '@rtk-incubator/rtk-query';
22

33
interface CountResponse {
44
count: number;
@@ -9,7 +9,9 @@ const baseQuery = retry(
99
baseUrl: '/',
1010
}),
1111
);
12-
export const counterApi = createApi({
12+
13+
// We use createBaseApi here as it is only the core and does not include any React-related code (such as hooks)
14+
export const counterApi = createBaseApi({
1315
reducerPath: 'counterApi',
1416
baseQuery,
1517
entityTypes: ['Counter'],

examples/svelte/src/store.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { configureStore, EnhancedStore } from '@reduxjs/toolkit';
22
import { counterApi } from './services/counter';
33
import { Readable, readable, writable } from 'svelte/store';
4+
import { setupListeners } from '@rtk-incubator/rtk-query';
45

56
const reduxStore = configureStore({
67
reducer: {
@@ -29,6 +30,8 @@ const bindReduxStore = <T extends EnhancedStore<any, any, any>>(
2930
};
3031
};
3132

33+
setupListeners(reduxStore.dispatch);
34+
3235
export const store = bindReduxStore(reduxStore);
3336

3437
export const globalPollingEnabled = writable(true);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
"limit": "15 KB"
6868
},
6969
{
70-
"name": "createPureApi + setupListeners",
70+
"name": "createBaseApi + setupListeners",
7171
"path": "dist/esm/index.js",
72-
"import": "{ createPureApi, setupListeners }"
72+
"import": "{ createBaseApi, setupListeners }"
7373
},
7474
{
7575
"name": "createApi + setupListeners",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export { setupListeners } from './core/setupListeners';
1515
export type { CreateApi, CreateApiOptions } from './createApi';
1616
export { buildCreateApi } from './createApi';
1717

18-
export { createApi as createPureApi, coreModule } from './core';
18+
export { createApi as createBaseApi, coreModule } from './core';
1919
export { createApi, reactHooksModule } from './react-hooks';

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
'concepts/optimistic-updates',
1313
'concepts/code-splitting',
1414
'concepts/code-generation',
15+
'concepts/customizing-create-api',
1516
],
1617
'API Reference': ['api/createApi', 'api/fetchBaseQuery', 'api/ApiProvider', 'api/setupListeners'],
1718
Examples: [

0 commit comments

Comments
 (0)