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

Introduce Infinite Query Support #4249

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
753a95b
correction of the refetch function type in useQuery documentation
domvo Dec 19, 2023
2d6ab29
Update `actions/checkout` usages to v4
aryaemami59 Feb 21, 2024
1c87574
Update example lockfiles
aryaemami59 Feb 21, 2024
26cba0a
Update all CI action usages
aryaemami59 Feb 24, 2024
18e4845
Merge branch 'reduxjs:master' into docs/correction-of-refetch-typing-…
domvo Feb 27, 2024
f808885
Added rough draft of initial endpoint definition for infinite query
riqts Mar 1, 2024
8711b24
Added placeholder select and initiate functions where the merge and q…
riqts Mar 1, 2024
19af0e2
Theoretical slice added to buildSlice to potentially handle changing …
riqts Mar 1, 2024
9b2990a
Added new endpointDefinition to createApi + module
riqts Mar 1, 2024
4d17105
Merge pull request #4234 from aryaemami59/update-examples-lockfiles
EskiMojo14 Mar 5, 2024
c21e260
Merge pull request #4233 from aryaemami59/actions-checkeout-v4
EskiMojo14 Mar 5, 2024
517d950
Merge branch 'master' of https://github.com/reduxjs/redux-toolkit int…
aryaemami59 Mar 5, 2024
14be7a2
Update `actions/setup-node` usages to v4 for `rtk-codemods`
aryaemami59 Mar 5, 2024
1315946
Fix configureStore enhancer section
EskiMojo14 Mar 6, 2024
e051ec9
tweak getDefaultEnhancers page
EskiMojo14 Mar 6, 2024
0ae8172
Added infiniteQueryThunks to core module file
riqts Mar 6, 2024
b612b8c
Initial implementation of executeEndpoint/Thunk with infiniteQuery
riqts Mar 6, 2024
eeb2140
Extended infiniteQueryInitiate, added fetchNextPage and fetchPrevious…
riqts Mar 6, 2024
dc6b156
Added types for InfiniteQueryConfig
riqts Mar 6, 2024
08dcaed
Update docs/rtk-query/api/created-api/hooks.mdx
domvo Mar 6, 2024
6c64f69
Merge pull request #4000 from domvo/docs/correction-of-refetch-typing…
EskiMojo14 Mar 7, 2024
95c4cbc
Merge pull request #4253 from reduxjs/enhancer-doc-fix
EskiMojo14 Mar 8, 2024
3b1fbf3
Merge branch 'master' of https://github.com/reduxjs/redux-toolkit int…
aryaemami59 Mar 8, 2024
5b16303
Merge pull request #4237 from aryaemami59/update-ci-actions
timdorr Mar 11, 2024
e31224f
Just build a RN bundle, not the whole app (#4266)
timdorr Mar 11, 2024
dced321
Added rough draft of initial endpoint definition for infinite query
riqts Mar 1, 2024
1f8ddc8
Added placeholder select and initiate functions where the merge and q…
riqts Mar 1, 2024
b1bbe33
Theoretical slice added to buildSlice to potentially handle changing …
riqts Mar 1, 2024
12ae77b
Added new endpointDefinition to createApi + module
riqts Mar 1, 2024
d1cb3d2
Added infiniteQueryThunks to core module file
riqts Mar 6, 2024
7fa52f0
Initial implementation of executeEndpoint/Thunk with infiniteQuery
riqts Mar 6, 2024
f2d0e56
Extended infiniteQueryInitiate, added fetchNextPage and fetchPrevious…
riqts Mar 6, 2024
c471ef8
Added types for InfiniteQueryConfig
riqts Mar 6, 2024
10ad756
Shelf
riqts Mar 20, 2024
1c4d41f
Built out initial react hook definitions for InfiniteQuery
riqts Apr 23, 2024
e0c952f
Merge remote-tracking branch 'origin/InfiniteQueryDefinition' into In…
riqts Apr 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Expand Up @@ -21,8 +21,8 @@ jobs:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/size.yml
Expand Up @@ -11,7 +11,7 @@ jobs:
env:
CI_JOB_NUMBER: 1
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: EskiMojo14/size-limit-action@v2
with:
directory: packages/toolkit
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-codegen.yml
Expand Up @@ -15,8 +15,8 @@ jobs:
outputs:
codegen: ${{ steps.filter.outputs.codegen }}
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
Expand All @@ -34,9 +34,9 @@ jobs:
node-version: ['20.x']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
Expand Down
42 changes: 22 additions & 20 deletions .github/workflows/tests.yml
Expand Up @@ -11,8 +11,8 @@ jobs:
outputs:
toolkit: ${{ steps.filter.outputs.toolkit }}
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
Expand All @@ -34,10 +34,10 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
Expand All @@ -55,7 +55,7 @@ jobs:
- name: Pack
run: yarn pack

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: package
path: packages/toolkit/package.tgz
Expand All @@ -70,18 +70,18 @@ jobs:
node: ['20.x']
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'yarn'

- name: Install deps
run: yarn install

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: package
path: packages/toolkit
Expand All @@ -108,10 +108,10 @@ jobs:
ts: ['4.7', '4.8', '4.9', '5.0', '5.1', '5.2', '5.3']
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
Expand All @@ -122,7 +122,7 @@ jobs:
- name: Install TypeScript ${{ matrix.ts }}
run: yarn add typescript@${{ matrix.ts }}

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: package
path: packages/toolkit
Expand Down Expand Up @@ -164,13 +164,13 @@ jobs:
run:
working-directory: ./examples/publish-ci/${{ matrix.example }}
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: "false"
YARN_ENABLE_IMMUTABLE_INSTALLS: false
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
Expand All @@ -181,7 +181,7 @@ jobs:
- name: Remove existing RTK
run: yarn remove @reduxjs/toolkit

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: package
path: ./examples/publish-ci/${{ matrix.example }}
Expand All @@ -197,13 +197,15 @@ jobs:

- name: Set up JDK 17 for React Native build
if: matrix.example == 'react-native' || matrix.example == 'expo'
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '17.x'
distribution: 'temurin'

- name: Build example
run: NODE_OPTIONS=--openssl-legacy-provider yarn build
env:
NODE_OPTIONS: --openssl-legacy-provider
run: yarn build

- name: Run test step
run: yarn test
Expand All @@ -219,18 +221,18 @@ jobs:
node: ['20.x']
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'yarn'

- name: Install deps
run: yarn install

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: package
path: packages/toolkit
Expand Down
20 changes: 11 additions & 9 deletions docs/api/configureStore.mdx
Expand Up @@ -154,14 +154,15 @@ An optional initial state value to be passed to the Redux `createStore` function

### `enhancers`

An optional array of Redux store enhancers, or a callback function to customize the array of enhancers.
A callback function to customize the array of enhancers.

If defined as an array, these will be passed to [the Redux `compose` function](https://redux.js.org/api/compose), and the combined enhancer will be passed to `createStore`.
Enhancers returned by this callback will be passed to [the Redux `compose` function](https://redux.js.org/api/compose), and the combined enhancer will be passed to `createStore`.

:::tip Dev Tools
This should _not_ include the Redux DevTools Extension `composeWithDevTools`, as this is already handled by `configureStore`.

Example: `enhancers: new Tuple(offline)` will result in a final setup of `[offline, devToolsExtension]`.
Example: `enhancers: () => new Tuple(offline)` will result in a final setup of `[offline, devToolsExtension]`.
:::

If not provided, `configureStore` will call `getDefaultEnhancers` and use the array of enhancers it returns (including `applyMiddleware` with specified middleware).

Expand All @@ -174,7 +175,7 @@ For more details on how the `enhancer` parameter works and the list of enhancers

:::caution Middleware

If you provide an array, this `applyMiddleware` enhancer will _not_ be used.
If you don't use `getDefaultEnhancers` and instead return an array, the `applyMiddleware` enhancer will _not_ be used.

`configureStore` will warn in console if any middleware are provided (or left as default) but not included in the final list of enhancers.

Expand All @@ -196,23 +197,24 @@ configureStore({
configureStore({
reducer,
middleware: () => [],
enhancers: () => [offline(offlineConfig)],
enhancers: () => [offline(offlineConfig)],
})
```

Note that if using Typescript, the `middleware` option is required to be provided _before_ the enhancer option, as the type of `getDefaultEnhancers` depends on its result.

:::

:::note Tuple
Typescript users are required to use a `Tuple` instance (if not using a `getDefaultEnhancer` result, which is already a `Tuple`), for better inference.

```
```ts no-transpile
import { configureStore, Tuple } from '@reduxjs/toolkit'

configureStore({
reducer: rootReducer,
enhancers: () => new Tuple(offline),
reducer: rootReducer,
enhancers: () => new Tuple(offline),
})

```

Javascript-only users are free to use a plain array if preferred.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/getDefaultEnhancers.mdx
Expand Up @@ -28,7 +28,7 @@ If you want to customise the list of enhancers, you can supply an array of enhan
```js
const store = configureStore({
reducer: rootReducer,
enhancers: [offline(offlineConfig)],
enhancers: () => new Tuple(offline(offlineConfig)),
})

// store specifically has the offline enhancer applied
Expand Down
2 changes: 1 addition & 1 deletion docs/rtk-query/api/created-api/hooks.mdx
Expand Up @@ -277,7 +277,7 @@ type UseQueryResult<T> = {
isSuccess: boolean // Query has data from a successful load.
isError: boolean // Query is currently in an "error" state.

refetch: () => void // A function to force refetch the query
refetch: () => QueryActionCreatorResult // A function to force refetch the query - returns a Promise with additional methods
}
```

Expand Down