Is there a way to skip the createResource query until a parameter is available?

Something similar to Tanstack Query or Apollo, maybe?
const [collations] = createResource(
async () => {
try {
const response = await hc.collations[":collationId"].$get({
param: {
collationId: routeParams!["collationId"],
},
});
return await response?.json();
} catch (e) {
return null;
}
},
{
skip: routeParams?.collationId,
}
);
const [collations] = createResource(
async () => {
try {
const response = await hc.collations[":collationId"].$get({
param: {
collationId: routeParams!["collationId"],
},
});
return await response?.json();
} catch (e) {
return null;
}
},
{
skip: routeParams?.collationId,
}
);
No description
3 Replies
Blankeos
BlankeosOP8mo ago
I'll probably just install TanStack haha
deluksic
deluksic8mo ago
If you return falsy from source, it will not run until it is truthy
peerreynders
peerreynders8mo ago
From: https://docs.solidjs.com/reference/basic-reactivity/create-resource.
or you can additionally pass a source signal as the first argument
Basically feed the parameter through a signal.
fetchData will be called as soon as source has any value other than false, null, or undefined.
as was already mentioned previously.
Want results from more Discord servers?
Add your server