S
SolidJS•3mo ago
chiefcll

createResource with a nested source signal doesn't retrigger

const [startTime, setStartTime] = createSignal(initialTime);
const [events, { refetch }] = createResource(
() => ({
service: channel,
startTime: startTime(),
duration: FOUR_HOUR_MILLISECONDS,
}),
epg.getEvents,
);
const [startTime, setStartTime] = createSignal(initialTime);
const [events, { refetch }] = createResource(
() => ({
service: channel,
startTime: startTime(),
duration: FOUR_HOUR_MILLISECONDS,
}),
epg.getEvents,
);
My source signal is an arrow function which returns an object that calls a signal for a value. When I setStartTime the epg.getEvents function is not called. Why is my startTime not being tracked properly?
5 Replies
chiefcll
chiefcllOP•3mo ago
PS - there is nothing async happening - I checked and getOwner does have a value... Even tried using on rather than arrow function
deluksic
deluksic•3mo ago
I dont see any issue with your code. Can you create a small repro on playground? Maybe you setStartTime to the same value so it doesn't trigger due to equal check?
chiefcll
chiefcllOP•3mo ago
Definitely a new value - I'll keep digging and see if I can setup a playground
Adam Goldstein
Adam Goldstein•3mo ago
You might want to try adding some logging, a few log statements for the resource source array accessor, the fetcher, and an effect on the startTime signal might make it clearer what is updating when. Apologies if you've already tried that, I just had a similar error and that helped me solve my own silly mistake 😃
chiefcll
chiefcllOP•3mo ago
Yea I've got a bunch of logging. I see there are 60 observers (which seems right) - And I see the setStartTime triggering with different values - and I have a console.log inside the source for createResource and that is never called again (after the first time)
Want results from more Discord servers?
Add your server