reactive initialValue on createResource

is it possible to make initialValue react based on a signal? I have this:

  const [namespaces] = createResource(contexts, fetchNamespaces, {
    initialValue: getCachedNamespaces(contexts()),
  });


Whenever the list of contexts change, it'll refetch the namespaces for that contexts. But the initialValue does not as it's evaluated once on render.

I want to build sort of a cache, so whenever the context changes, the list of namespaces will be whatever is cached (localstorage) and then it'll refresh shortly after.
Was this page helpful?