OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/frontend/app/components/api/api-v3/hal-resource-factory/hal-changeset-proxy.ts

24 lines
500 B

export interface ChangesetProxy {
changesetReset():void;
changesetPersist():void;
}
export function createChangeSetProxy<T>(target:T):T & ChangesetProxy {
const proxy = {} as any;
Object.setPrototypeOf(proxy, target);
proxy.changesetReset = () => {
_.forOwn(proxy, (value, key) => delete proxy[key!]);
};
proxy.changesetPersist = () => {
_.forOwn(proxy, (value, key) => {
(target as any)[key!] = value;
delete proxy[key!];
});
};
return proxy as any;
}