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

[Question] Usage with Redux Toolkits RTK Query #506

Open
cseelus opened this issue Mar 22, 2022 · 2 comments
Open

[Question] Usage with Redux Toolkits RTK Query #506

cseelus opened this issue Mar 22, 2022 · 2 comments

Comments

@cseelus
Copy link

cseelus commented Mar 22, 2022

According to this issue, integrating redux-offline with the Redux Toolkit store works fine. Strangely the apps authSlice seems to persist, despite redux-persist not (yet) being installed in this particular app.

Anyway, since RTK Query uses a specific notation to create request and mutation actions, is there a way to decorate these actions with offline metadata?

Basic RTK Query example

import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'

const api = createApi({
  baseQuery: fetchBaseQuery({
    baseUrl: '/',
  }),
  endpoints: (builder) => ({
    getComments: builder.query({
      query: () => ({ url: '/comments' })
    }),
    saveComment: builder.mutation({
      query: (comment) => ({
        url: '/comments',
        method: 'POST',
        body: comment,
      }),
    }),
  }),
})
@Hamzzay
Copy link

Hamzzay commented Mar 7, 2023

Hi @cseelus Did you manage to achieve this?

@cseelus
Copy link
Author

cseelus commented Mar 7, 2023

I didn't try, since I thought this repo wasn't maintained anymore, but might give it a try again in the next few weeks. If I find a solution, I'll post it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants