Ohm-Management - Projektarbeit B-ME
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.

proxyable.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.factory = factory;
  6. var _vue = require('vue');
  7. var _vue2 = _interopRequireDefault(_vue);
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  10. function factory() {
  11. var prop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'value';
  12. var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'change';
  13. return _vue2.default.extend({
  14. name: 'proxyable',
  15. model: {
  16. prop: prop,
  17. event: event
  18. },
  19. props: _defineProperty({}, prop, {
  20. required: false
  21. }),
  22. data: function data() {
  23. return {
  24. internalLazyValue: this[prop]
  25. };
  26. },
  27. computed: {
  28. internalValue: {
  29. get: function get() {
  30. return this.internalLazyValue;
  31. },
  32. set: function set(val) {
  33. if (val === this.internalLazyValue) return;
  34. this.internalLazyValue = val;
  35. this.$emit(event, val);
  36. }
  37. }
  38. },
  39. watch: _defineProperty({}, prop, function (val) {
  40. this.internalLazyValue = val;
  41. })
  42. });
  43. }
  44. /* eslint-disable-next-line no-redeclare */
  45. var Proxyable = factory();
  46. exports.default = Proxyable;
  47. //# sourceMappingURL=proxyable.js.map