vue-async-computed
Advanced tools
Comparing version 3.9.0 to 4.0.0-mixin.0
@@ -115,4 +115,2 @@ function setAsyncState (vm, stateObject, state) { | ||
install (Vue, pluginOptions) { | ||
pluginOptions = pluginOptions || {}; | ||
Vue.config | ||
@@ -122,45 +120,50 @@ .optionMergeStrategies | ||
Vue.mixin({ | ||
data () { | ||
return { | ||
_asyncComputed: {}, | ||
} | ||
}, | ||
computed: { | ||
$asyncComputed () { | ||
return this.$data._asyncComputed | ||
} | ||
}, | ||
beforeCreate () { | ||
const asyncComputed = this.$options.asyncComputed || {}; | ||
Vue.mixin(getAsyncComputedMixin(pluginOptions)); | ||
} | ||
}; | ||
if (!Object.keys(asyncComputed).length) return | ||
function getAsyncComputedMixin (pluginOptions = {}) { | ||
return { | ||
data () { | ||
return { | ||
_asyncComputed: {}, | ||
} | ||
}, | ||
computed: { | ||
$asyncComputed () { | ||
return this.$data._asyncComputed | ||
} | ||
}, | ||
beforeCreate () { | ||
const asyncComputed = this.$options.asyncComputed || {}; | ||
for (const key in asyncComputed) { | ||
const getter = getterFn(key, asyncComputed[key]); | ||
this.$options.computed[prefix + key] = getter; | ||
} | ||
if (!Object.keys(asyncComputed).length) return | ||
this.$options.data = initDataWithAsyncComputed(this.$options, pluginOptions); | ||
}, | ||
created () { | ||
for (const key in this.$options.asyncComputed || {}) { | ||
const item = this.$options.asyncComputed[key], | ||
value = generateDefault.call(this, item, pluginOptions); | ||
if (isComputedLazy(item)) { | ||
silentSetLazy(this, key, value); | ||
} else { | ||
this[key] = value; | ||
} | ||
} | ||
for (const key in asyncComputed) { | ||
const getter = getterFn(key, asyncComputed[key]); | ||
this.$options.computed[prefix + key] = getter; | ||
} | ||
for (const key in this.$options.asyncComputed || {}) { | ||
handleAsyncComputedPropetyChanges(this, key, pluginOptions, Vue); | ||
this.$options.data = initDataWithAsyncComputed(this.$options, pluginOptions); | ||
}, | ||
created () { | ||
for (const key in this.$options.asyncComputed || {}) { | ||
const item = this.$options.asyncComputed[key], | ||
value = generateDefault.call(this, item, pluginOptions); | ||
if (isComputedLazy(item)) { | ||
silentSetLazy(this, key, value); | ||
} else { | ||
this[key] = value; | ||
} | ||
} | ||
}); | ||
for (const key in this.$options.asyncComputed || {}) { | ||
handleAsyncComputedPropetyChanges(this, key, pluginOptions); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
const AsyncComputedMixin = getAsyncComputedMixin(); | ||
function handleAsyncComputedPropetyChanges (vm, key, pluginOptions, Vue) { | ||
function handleAsyncComputedPropetyChanges (vm, key, pluginOptions) { | ||
let promiseId = 0; | ||
@@ -185,3 +188,3 @@ const watcher = newPromise => { | ||
setAsyncState(vm, key, 'error'); | ||
Vue.set(vm.$data._asyncComputed[key], 'exception', err); | ||
vm.$set(vm.$data._asyncComputed[key], 'exception', err); | ||
if (pluginOptions.errorHandler === false) return | ||
@@ -200,3 +203,3 @@ | ||
}; | ||
Vue.set(vm.$data._asyncComputed, key, { | ||
vm.$set(vm.$data._asyncComputed, key, { | ||
exception: null, | ||
@@ -285,1 +288,2 @@ update: () => { | ||
export default AsyncComputed; | ||
export { AsyncComputedMixin, AsyncComputed as AsyncComputedPlugin }; |
@@ -119,50 +119,55 @@ function setAsyncState(vm, stateObject, state) { | ||
install: function install(Vue, pluginOptions) { | ||
pluginOptions = pluginOptions || {}; | ||
Vue.config.optionMergeStrategies.asyncComputed = Vue.config.optionMergeStrategies.computed; | ||
Vue.mixin({ | ||
data: function data() { | ||
return { | ||
_asyncComputed: {} | ||
}; | ||
}, | ||
Vue.mixin(getAsyncComputedMixin(pluginOptions)); | ||
} | ||
}; | ||
computed: { | ||
$asyncComputed: function $asyncComputed() { | ||
return this.$data._asyncComputed; | ||
} | ||
}, | ||
beforeCreate: function beforeCreate() { | ||
var asyncComputed = this.$options.asyncComputed || {}; | ||
function getAsyncComputedMixin() { | ||
var pluginOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
if (!Object.keys(asyncComputed).length) return; | ||
return { | ||
data: function data() { | ||
return { | ||
_asyncComputed: {} | ||
}; | ||
}, | ||
for (var key in asyncComputed) { | ||
var getter = getterFn(key, asyncComputed[key]); | ||
this.$options.computed[prefix + key] = getter; | ||
} | ||
computed: { | ||
$asyncComputed: function $asyncComputed() { | ||
return this.$data._asyncComputed; | ||
} | ||
}, | ||
beforeCreate: function beforeCreate() { | ||
var asyncComputed = this.$options.asyncComputed || {}; | ||
this.$options.data = initDataWithAsyncComputed(this.$options, pluginOptions); | ||
}, | ||
created: function created() { | ||
for (var key in this.$options.asyncComputed || {}) { | ||
var item = this.$options.asyncComputed[key], | ||
value = generateDefault.call(this, item, pluginOptions); | ||
if (isComputedLazy(item)) { | ||
silentSetLazy(this, key, value); | ||
} else { | ||
this[key] = value; | ||
} | ||
} | ||
if (!Object.keys(asyncComputed).length) return; | ||
for (var _key in this.$options.asyncComputed || {}) { | ||
handleAsyncComputedPropetyChanges(this, _key, pluginOptions, Vue); | ||
for (var key in asyncComputed) { | ||
var getter = getterFn(key, asyncComputed[key]); | ||
this.$options.computed[prefix + key] = getter; | ||
} | ||
this.$options.data = initDataWithAsyncComputed(this.$options, pluginOptions); | ||
}, | ||
created: function created() { | ||
for (var key in this.$options.asyncComputed || {}) { | ||
var item = this.$options.asyncComputed[key], | ||
value = generateDefault.call(this, item, pluginOptions); | ||
if (isComputedLazy(item)) { | ||
silentSetLazy(this, key, value); | ||
} else { | ||
this[key] = value; | ||
} | ||
} | ||
}); | ||
} | ||
}; | ||
function handleAsyncComputedPropetyChanges(vm, key, pluginOptions, Vue) { | ||
for (var _key in this.$options.asyncComputed || {}) { | ||
handleAsyncComputedPropetyChanges(this, _key, pluginOptions); | ||
} | ||
} | ||
}; | ||
} | ||
var AsyncComputedMixin = getAsyncComputedMixin(); | ||
function handleAsyncComputedPropetyChanges(vm, key, pluginOptions) { | ||
var promiseId = 0; | ||
@@ -187,3 +192,3 @@ var watcher = function watcher(newPromise) { | ||
setAsyncState(vm, key, 'error'); | ||
Vue.set(vm.$data._asyncComputed[key], 'exception', err); | ||
vm.$set(vm.$data._asyncComputed[key], 'exception', err); | ||
if (pluginOptions.errorHandler === false) return; | ||
@@ -200,3 +205,3 @@ | ||
}; | ||
Vue.set(vm.$data._asyncComputed, key, { | ||
vm.$set(vm.$data._asyncComputed, key, { | ||
exception: null, | ||
@@ -283,1 +288,2 @@ update: function update() { | ||
export default AsyncComputed; | ||
export { AsyncComputedMixin, AsyncComputed as AsyncComputedPlugin }; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.AsyncComputed = factory()); | ||
}(this, (function () { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.AsyncComputed = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
@@ -121,4 +121,2 @@ function setAsyncState (vm, stateObject, state) { | ||
install (Vue, pluginOptions) { | ||
pluginOptions = pluginOptions || {}; | ||
Vue.config | ||
@@ -128,45 +126,50 @@ .optionMergeStrategies | ||
Vue.mixin({ | ||
data () { | ||
return { | ||
_asyncComputed: {}, | ||
} | ||
}, | ||
computed: { | ||
$asyncComputed () { | ||
return this.$data._asyncComputed | ||
} | ||
}, | ||
beforeCreate () { | ||
const asyncComputed = this.$options.asyncComputed || {}; | ||
Vue.mixin(getAsyncComputedMixin(pluginOptions)); | ||
} | ||
}; | ||
if (!Object.keys(asyncComputed).length) return | ||
function getAsyncComputedMixin (pluginOptions = {}) { | ||
return { | ||
data () { | ||
return { | ||
_asyncComputed: {}, | ||
} | ||
}, | ||
computed: { | ||
$asyncComputed () { | ||
return this.$data._asyncComputed | ||
} | ||
}, | ||
beforeCreate () { | ||
const asyncComputed = this.$options.asyncComputed || {}; | ||
for (const key in asyncComputed) { | ||
const getter = getterFn(key, asyncComputed[key]); | ||
this.$options.computed[prefix + key] = getter; | ||
} | ||
if (!Object.keys(asyncComputed).length) return | ||
this.$options.data = initDataWithAsyncComputed(this.$options, pluginOptions); | ||
}, | ||
created () { | ||
for (const key in this.$options.asyncComputed || {}) { | ||
const item = this.$options.asyncComputed[key], | ||
value = generateDefault.call(this, item, pluginOptions); | ||
if (isComputedLazy(item)) { | ||
silentSetLazy(this, key, value); | ||
} else { | ||
this[key] = value; | ||
} | ||
} | ||
for (const key in asyncComputed) { | ||
const getter = getterFn(key, asyncComputed[key]); | ||
this.$options.computed[prefix + key] = getter; | ||
} | ||
for (const key in this.$options.asyncComputed || {}) { | ||
handleAsyncComputedPropetyChanges(this, key, pluginOptions, Vue); | ||
this.$options.data = initDataWithAsyncComputed(this.$options, pluginOptions); | ||
}, | ||
created () { | ||
for (const key in this.$options.asyncComputed || {}) { | ||
const item = this.$options.asyncComputed[key], | ||
value = generateDefault.call(this, item, pluginOptions); | ||
if (isComputedLazy(item)) { | ||
silentSetLazy(this, key, value); | ||
} else { | ||
this[key] = value; | ||
} | ||
} | ||
}); | ||
for (const key in this.$options.asyncComputed || {}) { | ||
handleAsyncComputedPropetyChanges(this, key, pluginOptions); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
const AsyncComputedMixin = getAsyncComputedMixin(); | ||
function handleAsyncComputedPropetyChanges (vm, key, pluginOptions, Vue) { | ||
function handleAsyncComputedPropetyChanges (vm, key, pluginOptions) { | ||
let promiseId = 0; | ||
@@ -191,3 +194,3 @@ const watcher = newPromise => { | ||
setAsyncState(vm, key, 'error'); | ||
Vue.set(vm.$data._asyncComputed[key], 'exception', err); | ||
vm.$set(vm.$data._asyncComputed[key], 'exception', err); | ||
if (pluginOptions.errorHandler === false) return | ||
@@ -206,3 +209,3 @@ | ||
}; | ||
Vue.set(vm.$data._asyncComputed, key, { | ||
vm.$set(vm.$data._asyncComputed, key, { | ||
exception: null, | ||
@@ -290,4 +293,8 @@ update: () => { | ||
return AsyncComputed; | ||
exports.AsyncComputedMixin = AsyncComputedMixin; | ||
exports.AsyncComputedPlugin = AsyncComputed; | ||
exports.default = AsyncComputed; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); |
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
(function (global, factory) { | ||
(typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.AsyncComputed = factory()); | ||
})(this, function () { | ||
(typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.AsyncComputed = {})); | ||
})(this, function (exports) { | ||
'use strict'; | ||
@@ -126,50 +126,55 @@ | ||
install: function install(Vue, pluginOptions) { | ||
pluginOptions = pluginOptions || {}; | ||
Vue.config.optionMergeStrategies.asyncComputed = Vue.config.optionMergeStrategies.computed; | ||
Vue.mixin({ | ||
data: function data() { | ||
return { | ||
_asyncComputed: {} | ||
}; | ||
}, | ||
Vue.mixin(getAsyncComputedMixin(pluginOptions)); | ||
} | ||
}; | ||
computed: { | ||
$asyncComputed: function $asyncComputed() { | ||
return this.$data._asyncComputed; | ||
} | ||
}, | ||
beforeCreate: function beforeCreate() { | ||
var asyncComputed = this.$options.asyncComputed || {}; | ||
function getAsyncComputedMixin() { | ||
var pluginOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
if (!Object.keys(asyncComputed).length) return; | ||
return { | ||
data: function data() { | ||
return { | ||
_asyncComputed: {} | ||
}; | ||
}, | ||
for (var key in asyncComputed) { | ||
var getter = getterFn(key, asyncComputed[key]); | ||
this.$options.computed[prefix + key] = getter; | ||
} | ||
computed: { | ||
$asyncComputed: function $asyncComputed() { | ||
return this.$data._asyncComputed; | ||
} | ||
}, | ||
beforeCreate: function beforeCreate() { | ||
var asyncComputed = this.$options.asyncComputed || {}; | ||
this.$options.data = initDataWithAsyncComputed(this.$options, pluginOptions); | ||
}, | ||
created: function created() { | ||
for (var key in this.$options.asyncComputed || {}) { | ||
var item = this.$options.asyncComputed[key], | ||
value = generateDefault.call(this, item, pluginOptions); | ||
if (isComputedLazy(item)) { | ||
silentSetLazy(this, key, value); | ||
} else { | ||
this[key] = value; | ||
} | ||
} | ||
if (!Object.keys(asyncComputed).length) return; | ||
for (var _key in this.$options.asyncComputed || {}) { | ||
handleAsyncComputedPropetyChanges(this, _key, pluginOptions, Vue); | ||
for (var key in asyncComputed) { | ||
var getter = getterFn(key, asyncComputed[key]); | ||
this.$options.computed[prefix + key] = getter; | ||
} | ||
this.$options.data = initDataWithAsyncComputed(this.$options, pluginOptions); | ||
}, | ||
created: function created() { | ||
for (var key in this.$options.asyncComputed || {}) { | ||
var item = this.$options.asyncComputed[key], | ||
value = generateDefault.call(this, item, pluginOptions); | ||
if (isComputedLazy(item)) { | ||
silentSetLazy(this, key, value); | ||
} else { | ||
this[key] = value; | ||
} | ||
} | ||
}); | ||
} | ||
}; | ||
function handleAsyncComputedPropetyChanges(vm, key, pluginOptions, Vue) { | ||
for (var _key in this.$options.asyncComputed || {}) { | ||
handleAsyncComputedPropetyChanges(this, _key, pluginOptions); | ||
} | ||
} | ||
}; | ||
} | ||
var AsyncComputedMixin = getAsyncComputedMixin(); | ||
function handleAsyncComputedPropetyChanges(vm, key, pluginOptions) { | ||
var promiseId = 0; | ||
@@ -194,3 +199,3 @@ var watcher = function watcher(newPromise) { | ||
setAsyncState(vm, key, 'error'); | ||
Vue.set(vm.$data._asyncComputed[key], 'exception', err); | ||
vm.$set(vm.$data._asyncComputed[key], 'exception', err); | ||
if (pluginOptions.errorHandler === false) return; | ||
@@ -207,3 +212,3 @@ | ||
}; | ||
Vue.set(vm.$data._asyncComputed, key, { | ||
vm.$set(vm.$data._asyncComputed, key, { | ||
exception: null, | ||
@@ -289,3 +294,7 @@ update: function update() { | ||
return AsyncComputed; | ||
exports.AsyncComputedMixin = AsyncComputedMixin; | ||
exports.AsyncComputedPlugin = AsyncComputed; | ||
exports.default = AsyncComputed; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}); |
{ | ||
"name": "vue-async-computed", | ||
"version": "3.9.0", | ||
"version": "4.0.0-mixin.0", | ||
"description": "Async computed properties for Vue", | ||
@@ -5,0 +5,0 @@ "main": "dist/vue-async-computed.js", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
55457
1019
1