model.js 1.0 KB

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