8
0

model.js 976 B

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