I am using refreshApex
to get the latest data with a button. There is a possibility that there are no new changes and I want to display a message indicating there are no new changes.
Question
- How can I detect if there are changes or no changes when using the
refreshApex
method?
What I tried so far but no luck
myComponent.js
import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
export default class Record extends LightningElement {
@api recorded;
wiredRecord;
@wire(getRecord, { recordId: '$recordId', fields: ['Account.Name'] })
wiredActivity(value) {
this.wiredRecord = value;
const {data, error} = value;
if(data) { ... }
else if (error) { ... }
}
handleClick() {
refreshApex(this.wiredRecord);
// I can't figure out how to check if different ---- help here
}
}
myComponent.html
<template>
...
<button onclick={handleClick}>My button</button>
...
</template>