does createResource with multiple signals trigger when onMount
if createResource has one signal which is false as dependency, the resource will be trigger as the signal changing. However, if I set two signals as dependency, the resource triggers in every mount alougth the signals are false .
Is there any methods to avoid trigger fetcher when the group signals are false?
thanks a lot
4 Replies
If I'm understanding this right,. The sourcesignals are passed as params to the fetcher even if they're
false
, so you can avoid fetching depending on the value of any of those.
They aren't match conditions to execute createResource
or not, they're params passed to the fetcher call.
like checking values of dataVal
or moreDataVal
in the example above.createResource
will trigger whenever the value added as the source is truthy. In the case of adding multiple values, such as createResource(() => [signal1(), signal2()], () => {})
, the fetcher will always run as the array will be truthy even if both values are falsy. To prevent the fetcher from running if both signals are falsy, you can use a ternary to make the source evaluate to false if both conditions are false, such as:Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
got it, thanks a lot
thanks, I know how to use the createResrouce now.