collectObserver.js 463 B

123456789101112131415
  1. function collectObserver(observerObj, option, ctx) {
  2. Object.keys(option).forEach((prop) => {
  3. if (typeof option[prop] !== 'object' || !option[prop]) { return false }
  4. if (option[prop].observer) {
  5. if (typeof option[prop].observer === 'string') {
  6. observerObj[prop] = ctx.methods[option[prop].observer]
  7. } else {
  8. observerObj[prop] = option[prop].observer
  9. }
  10. }
  11. })
  12. return observerObj
  13. }
  14. module.exports = collectObserver