Skip to content

RTK Query: Do we have a manual fetch function that follows cache rules as auto-fetch do #1776

Answered by phryneas
xiaoyangfeng asked this question in Q&A
Discussion options

You must be logged in to vote

You can do that by doing

const request = dispatch(
    api.endpoints.myEndpoint.initiate(arg, {
        forceRefetch: 30,
    })
)
// make sure to call this before your component unmounts or the data will never be removed from the cache
request.unsubscribe()

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
9 replies
@xiaoyangfeng
Comment options

@zousandian
Comment options

@phryneas
Comment options

@zousandian
Comment options

@phryneas
Comment options

Comment options

You must be logged in to vote
2 replies
@xiaoyangfeng
Comment options

@phryneas
Comment options

Answer selected by xiaoyangfeng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants