collectObserver.js 882 B

12345678910111213141516171819202122
  1. "use strict";
  2. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3. function collectObserver(observerObj, option, ctx) {
  4. Object.keys(option).forEach(function (prop) {
  5. if (_typeof(option[prop]) !== 'object' || !option[prop]) {
  6. return false;
  7. }
  8. if (option[prop].observer) {
  9. if (typeof option[prop].observer === 'string') {
  10. observerObj[prop] = ctx.methods[option[prop].observer];
  11. } else {
  12. observerObj[prop] = option[prop].observer;
  13. }
  14. }
  15. });
  16. return observerObj;
  17. }
  18. module.exports = collectObserver;