model.js 951 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import extend from '../utils/lib/lodash/extend.js';
  6. import mix from '../utils/mix.js';
  7. import ObservableMixin from '../utils/observablemixin.js';
  8. /**
  9. * The base MVC model class.
  10. *
  11. * @memberOf ui
  12. * @mixes utils.ObservaleMixin
  13. */
  14. export default class Model {
  15. /**
  16. * Creates a new Model instance.
  17. *
  18. * @param {Object} [attributes] The model state attributes to be defined during the instance creation.
  19. * @param {Object} [properties] The (out of state) properties to be appended to the instance during creation.
  20. */
  21. constructor( attributes, properties ) {
  22. // Extend this instance with the additional (out of state) properties.
  23. if ( properties ) {
  24. extend( this, properties );
  25. }
  26. // Initialize the attributes.
  27. if ( attributes ) {
  28. this.set( attributes );
  29. }
  30. }
  31. }
  32. mix( Model, ObservableMixin );