afraid-scarlet
afraid-scarlet17mo ago

getIdentity

Hi, is there a way we can update the state of our getIdentity, after updating a certain component belonging to our user, without fetching new data from the database? Is it better to use liveProvider? if so which provider would be best along with nodejs express backend?
6 Replies
kapa.ai
kapa.ai17mo ago
Hey @RomaY! I'm the kapa.ai support bot. I've searched through the docs to try to answer your question. :wave:
kapa.ai
kapa.ai17mo ago
---------------------- Based on the information provided in the extracts, the getIdentity method is used to get the user's identity and is called by the useGetIdentity hook. However, there is no direct way to update the state of getIdentity without fetching new data from the database. Regarding the liveProvider, it is used to add real-time support to your application, allowing you to update and show data in real-time throughout your app. You can use any real-time library or tool that you want with your Node.js Express backend. The liveProvider must have the following properties:
const liveProvider = {
subscribe: ({ channel, params: { ids }, types, callback }) => any,
unsubscribe: (subscription) => void,
publish?: (event) => void,
};
const liveProvider = {
subscribe: ({ channel, params: { ids }, types, callback }) => any,
unsubscribe: (subscription) => void,
publish?: (event) => void,
};
However, the liveProvider is more focused on real-time updates for data resources rather than updating the state of getIdentity. It might not be the best solution for your specific use case. For more information on liveProvider, you can refer to the Live / Realtime (https://refine.dev/docs/api-reference/core/providers/live-provider/#livemode) page and the Real-time support (https://refine.dev/blog/build-internal-tools-using-low-code-with-refine/#real-time-support) section in the blog post. ----------------------
Build internal tools using Low-Code with Refine, React-based framew...
Why you should be using low-code app Refine to build internal tools? Learn how to build low-code apps using Refine, React and Ant Design.
kapa.ai
kapa.ai17mo ago
<@538717491908575242> kapa.ai is still learning and improving, please let us how it did by reacting below
robust-apricot
robust-apricot17mo ago
Hey @RomaY you can update the query cache, the key of the useGetIdentity starts with getUserIdentity. You can also check the exact key through react query dev tools at the bottom right corner
afraid-scarlet
afraid-scarlet17mo ago
I am building a commercial web application, I wonder if there is a way to update certain data of our user (add/delete to/from favorites) or do I need to use liveProvider to query the database? So I'm adding data to my user, but I don't want to get my user again, is it possible to update my getIdentity on a successful request?
correct-apricot
correct-apricot17mo ago
getIdendity works through auth provider. refine liveProvider automatically updates only datasets running through the resoruce. So you should either invalidate the getIdenity request or use the refetch method.