function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raksha NarayanRaksha Narayan 

Call wire method from another method in LWC

I have a button which is a quick action and I am calling a LWC and the logic is handled in the invoke method. Below is the LWC structure.

@wire(getRecord)
.
.
@wire(getRelatedListRecords)
.
.
@api invoke(){
..
}

I want to call @wire(getRelatedListRecords) in the invoke method or I want to reload the LWC component on clicking the button. 
Is this possible? 
 
Naveen KNNaveen KN
You can call apex method on click a button (https://www.codekiat.com/2020/04/call-apex-method-on-button-click-in-lwc.html) and refresh the data in your lightning web component. Any specific reason you want to call the wire method on click of a button?
Raksha NarayanRaksha Narayan
The wire method is holding the old data. I am deleting the child record and the wire method is not updated with the total no. of child records. So I want to call the getRelatedListRecords again.
Naveen KNNaveen KN
ok. Can we refreshApex() here?

Salesforce Doc:
To refresh Apex data provisioned via an Apex @wire, call refreshApex(). The function provisions the data using the configuration bound to the @wire and updates the cache.

NOTE The parameter you refresh with refreshApex() must be an object that was previously emitted by an Apex @wire.The parameter you refresh with refreshApex() must be an object that was previously emitted by an Apex @wire.

more details here https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.apex_result_caching

please try and let us know if works. Thanks.