So in my service I am setting the signal
symbolChangeSignal = signal<number>(0);
now in component ABC i am creating resource
request: () => {
let script = this.stateService.symbolChangeSignal()
},
loader: ({ request }) => {
return apicallhere
}
});
ponent.ts
take a look at this example In above you will find a service which on app load intitialized id signal with init value 0.
In app child there is rxResource using this signal. But app child comes in play after 1 second. Only after that child component rxResource is intitialized. How come resource is making an API call and loading data here using id value 1. Even though signal value is not changed after resource declare/init.
The document states that the resource produces a new request value on signal change. However, it is not mentioned anywhere in the document that upon resource initialization, the loader will be called once using the previous value or initialised value of the signal.
So in my service I am setting the signal
symbolChangeSignal = signal<number>(0);
now in component ABC i am creating resource
request: () => {
let script = this.stateService.symbolChangeSignal()
},
loader: ({ request }) => {
return apicallhere
}
});
https://stackblitz.com/edit/stackblitz-starters-mjzjkrpq?file=src%2Fapp%2Fchild.component.ts
take a look at this example In above you will find a service which on app load intitialized id signal with init value 0.
In app child there is rxResource using this signal. But app child comes in play after 1 second. Only after that child component rxResource is intitialized. How come resource is making an API call and loading data here using id value 1. Even though signal value is not changed after resource declare/init.
The document states that the resource produces a new request value on signal change. However, it is not mentioned anywhere in the document that upon resource initialization, the loader will be called once using the previous value or initialised value of the signal.
Share Improve this question asked Feb 7 at 8:30 Nikunj GunaNikunj Guna 212 bronze badges1 Answer
Reset to default 0I'll give you the same answer here,
Resources are eager, they evaluate the request and pass that value down to the loader which will eventually return the value of the resource.
And on subsequents changes of the request signals, the request will be recomputed and re-trigger the loader.
This is the same way an effect or a computed would work.