This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/models/abstractModel.js
kolaente fe6c859150
All checks were successful
continuous-integration/drone/push Build is passing
Revert "Use deep imports for importing lodash to make tree shaking easier"
This reverts commit 3c3767a9
2020-03-03 21:02:13 +01:00

21 lines
513 B
JavaScript

import {defaults, omitBy, isNil} from 'lodash'
export default class AbstractModel {
/**
* The abstract constructor takes an object and merges its data with the default data of this model.
* @param data
*/
constructor(data) {
// Put all data in our model while overriding those with a value of null or undefined with their defaults
defaults(this, omitBy(data, isNil), this.defaults())
}
/**
* Default attributes that define the "empty" state.
* @return {{}}
*/
defaults() {
return {}
}
}