In my typescript class I have skip
function. In my interface
I have mentioned data coming from backend.
On the front end
I would like to rename the backend variable
as shown below. There are multiple variables, how can I optimize the code
?
I thought of using Destructuring concept but not sure how to use. I need help
this.recordId = data?.data1;
this.oldValue = data?.data2;
this.newValue = data?.data3;
............// many more
ts function
skip(rec: ABC) {
const { data1, data2, data3 } = rec;
this.records.skip({ data1, data2, data3}).subscribe(data => {
this.recordId = data?.data1; ---------------------------->Here
this.oldValue = data?.data2; ---------------------------->
this.newValue = data?.data3; ---------------------------->
............// many more
this.processIncomingRecord(data);
});
}
rec.ts
export interface ABC {
data1: number;
data2: number;
data3: number;
}