1

I always use refreshApex to refresh the condition after some soql action or something else, I find out that refreshApex only work on plain parameter, for example:

@wire(someMethod, {Id: '$recordId'}) result({error, data}) { if (data) {...} else if (error) {...} } @wire(someMethod, {Id: '$recordId'}) dummyResult handleChange(e) { refreshApex(this.result) // this won't work refreshApex(this.dummyresult) // this works } 

And the amazing part is that if I refresh the dummyResult, all the code inside if (data) will be excuted(just what I want), can someone explain why?

1 Answer 1

2

as per doc refreshApex method accepts valueProvisionedByWireService that means

@wire(someMethod, {Id: '$recordId'}) wiredsomeMethod(result){ this.dummyResult = result; // Hold on to the provisioned value so we can refresh it later. /// your data check and error check logic } handleChange(e) { refreshApex(this.dummyresult) } 

why 'refreshApex(this.result) // this won't work

because you are using Object destructing for your convenience, in this process losing the provisioned value itself

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.