]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/classes/cd-helper.class.ts
import ceph pacific 16.2.5
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / classes / cd-helper.class.ts
CommitLineData
b3b6e05e 1import _ from 'lodash';
f67539c2
TL
2
3export class CdHelperClass {
4 /**
5 * Simple way to only update variables if they have really changed and not just the reference
6 *
7 * @param componentThis - In order to update the variables if necessary
8 * @param change - The variable name (attribute of the object) is followed by the current value
9 * it would update even if it equals
10 */
11 static updateChanged(componentThis: any, change: { [publicVarName: string]: any }) {
12 let hasChanges = false;
13
14 Object.keys(change).forEach((publicVarName) => {
15 const data = change[publicVarName];
16 if (!_.isEqual(data, componentThis[publicVarName])) {
17 componentThis[publicVarName] = data;
18 hasChanges = true;
19 }
20 });
21
22 return hasChanges;
23 }
24}