Is it possible to get createAsync to revaluate/ refetch data like createResource?

I see the example here but I'm still not understanding it
GitHub
GitHub - solidjs/solid-router: A universal router for Solid inspire...
A universal router for Solid inspired by Ember and React Router - solidjs/solid-router
7 Replies
Birk Skyum
Birk Skyum3mo ago
If you have a cache function, and use it inside a createAsync, then should be able to do a cache revalidate, and my understanding is that it will trigger an update of the createAsync
Birk Skyum
Birk Skyum3mo ago
GitHub
GitHub - solidjs/solid-router: A universal router for Solid inspire...
A universal router for Solid inspired by Ember and React Router - solidjs/solid-router
Carlo Nyte
Carlo Nyte3mo ago
I read that but don't understand how or what trigger the revalidate? Would you be able to give me an example?
Birk Skyum
Birk Skyum3mo ago
Yes, so you can import {revalidate} from the @solidjs/router
// say `getUser` is a cache
getUser.key;

// which is used in a createAsync:
const user = createAsync(() => getUser(props.params.id));

// revalidate(key?: string | string[] | void);
await revalidate(getUser.key);
// say `getUser` is a cache
getUser.key;

// which is used in a createAsync:
const user = createAsync(() => getUser(props.params.id));

// revalidate(key?: string | string[] | void);
await revalidate(getUser.key);
Carlo Nyte
Carlo Nyte3mo ago
ah it's an actual function got it! Thank you
Birk Skyum
Birk Skyum3mo ago
When you've tried, let me know if it works for you
Carlo Nyte
Carlo Nyte3mo ago
I ended up not needing to refetch because I could use the data in the ui to get the value I needed. (I was added data to a list and was thinking of using refetch/ revalidate to get the new number of items in the list but its faster just to add the new item to the existing length of list to get the total @Birk Skyum Thank you for you're help!
Want results from more Discord servers?
Add your server
More Posts
[solved] Can't use `@solidjs/router` in external package for SolidStartI'm trying to write a library for my SolidStart project & need to use the `A` component exported froSeems like I found a JSX bugAs long I know, you can add up variables and raw text inside a tag, something like: `<p>{myVar} peopHow can I protect nothing ever breaks, while the setTimeout is waiting```tsx createEffect(() => { if (puzzle_lala().is_revealed && is_jump_to_next_puzzle_immeCanonical way to handle exceptions in async functions to perform redirect?Hi folks, I'm very new to solid and frontend development hence my question. I have a class that talk[solved]Issue with Solid Start MDX Project: 404 Error for New PageHello, I have created a Solid Start project using the “with MDX” mode. By default, the navigation inTrying SolidJS + Deno + ViteJS + Solid-Router + TailwindCSS, would love some help :)Hello, all 😄 I'm trying to run SolidJS with Deno & ViteJS, thus I'm using a new plugin made by commHow to css preloadingWhen the file weighs a lot, I don’t immediately see the application of styles on the site. I connecHandling of sensitive information from the front endHello, I am new in front end, now I am trying to make some components, that are shown/hidden dependiResource with async cacheWhats the pattern for using resources with caching that may be async? What I mean by that is that myGetting this error - TypeError: Cannot read properties of null (reading '_isDirty')Hi all! I am trying to create a simple home page using lighting Solid JS something like a netflix p