vue-async-computed
Advanced tools
Comparing version 3.7.0 to 3.8.0
@@ -5,2 +5,3 @@ <!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
- [v3.8.0](#v380) | ||
- [v3.7.0](#v370) | ||
@@ -31,2 +32,7 @@ - [v3.6.1](#v361) | ||
### v3.8.0 | ||
* [#83](https://github.com/foxbenjaminfox/vue-async-computed/pull/83) Stop the update method from working after the component is destroyed. | ||
* Include the long-requested ([#25](https://github.com/foxbenjaminfox/vue-async-computed/issues/25)) typescript types in the `master` branch. | ||
* [#85](https://github.com/foxbenjaminfox/vue-async-computed/pull/85) Add support in the typescript types for the array of strings version of `watch`. | ||
### v3.7.0 | ||
@@ -33,0 +39,0 @@ * [#68](https://github.com/foxbenjaminfox/vue-async-computed/pull/68) Refactoring to make some of the code be more readable. |
@@ -0,3 +1,20 @@ | ||
function setAsyncState (vm, stateObject, state) { | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'state', state); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'updating', state === 'updating'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'error', state === 'error'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'success', state === 'success'); | ||
} | ||
function getterOnly (fn) { | ||
if (typeof fn === 'function') return fn | ||
return fn.get | ||
} | ||
function hasOwnProperty (object, property) { | ||
return Object.prototype.hasOwnProperty.call(object, property) | ||
} | ||
function isComputedLazy (item) { | ||
return item.hasOwnProperty('lazy') && item.lazy | ||
return hasOwnProperty(item, 'lazy') && item.lazy | ||
} | ||
@@ -145,2 +162,3 @@ | ||
}; | ||
function handleAsyncComputedPropetyChanges (vm, key, pluginOptions, Vue) { | ||
@@ -183,3 +201,5 @@ let promiseId = 0; | ||
update: () => { | ||
watcher(getterOnly(vm.$options.asyncComputed[key]).apply(vm)); | ||
if (!vm._isDestroyed) { | ||
watcher(getterOnly(vm.$options.asyncComputed[key]).apply(vm)); | ||
} | ||
} | ||
@@ -212,15 +232,2 @@ }); | ||
function setAsyncState (vm, stateObject, state) { | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'state', state); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'updating', state === 'updating'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'error', state === 'error'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'success', state === 'success'); | ||
} | ||
function getterOnly (fn) { | ||
if (typeof fn === 'function') return fn | ||
return fn.get | ||
} | ||
function getterFn (key, fn) { | ||
@@ -231,7 +238,7 @@ if (typeof fn === 'function') return fn | ||
if (fn.hasOwnProperty('watch')) { | ||
if (hasOwnProperty(fn, 'watch')) { | ||
getter = getWatchedGetter(fn); | ||
} | ||
if (fn.hasOwnProperty('shouldUpdate')) { | ||
if (hasOwnProperty(fn, 'shouldUpdate')) { | ||
getter = getGetterWithShouldUpdate(fn, getter); | ||
@@ -238,0 +245,0 @@ } |
@@ -0,3 +1,20 @@ | ||
function setAsyncState(vm, stateObject, state) { | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'state', state); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'updating', state === 'updating'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'error', state === 'error'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'success', state === 'success'); | ||
} | ||
function getterOnly(fn) { | ||
if (typeof fn === 'function') return fn; | ||
return fn.get; | ||
} | ||
function hasOwnProperty(object, property) { | ||
return Object.prototype.hasOwnProperty.call(object, property); | ||
} | ||
function isComputedLazy(item) { | ||
return item.hasOwnProperty('lazy') && item.lazy; | ||
return hasOwnProperty(item, 'lazy') && item.lazy; | ||
} | ||
@@ -148,2 +165,3 @@ | ||
}; | ||
function handleAsyncComputedPropetyChanges(vm, key, pluginOptions, Vue) { | ||
@@ -184,3 +202,5 @@ var promiseId = 0; | ||
update: function update() { | ||
watcher(getterOnly(vm.$options.asyncComputed[key]).apply(vm)); | ||
if (!vm._isDestroyed) { | ||
watcher(getterOnly(vm.$options.asyncComputed[key]).apply(vm)); | ||
} | ||
} | ||
@@ -211,15 +231,2 @@ }); | ||
function setAsyncState(vm, stateObject, state) { | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'state', state); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'updating', state === 'updating'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'error', state === 'error'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'success', state === 'success'); | ||
} | ||
function getterOnly(fn) { | ||
if (typeof fn === 'function') return fn; | ||
return fn.get; | ||
} | ||
function getterFn(key, fn) { | ||
@@ -230,7 +237,7 @@ if (typeof fn === 'function') return fn; | ||
if (fn.hasOwnProperty('watch')) { | ||
if (hasOwnProperty(fn, 'watch')) { | ||
getter = getWatchedGetter(fn); | ||
} | ||
if (fn.hasOwnProperty('shouldUpdate')) { | ||
if (hasOwnProperty(fn, 'shouldUpdate')) { | ||
getter = getGetterWithShouldUpdate(fn, getter); | ||
@@ -237,0 +244,0 @@ } |
@@ -5,6 +5,23 @@ (function (global, factory) { | ||
(global = global || self, global.AsyncComputed = factory()); | ||
}(this, function () { 'use strict'; | ||
}(this, (function () { 'use strict'; | ||
function setAsyncState (vm, stateObject, state) { | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'state', state); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'updating', state === 'updating'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'error', state === 'error'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'success', state === 'success'); | ||
} | ||
function getterOnly (fn) { | ||
if (typeof fn === 'function') return fn | ||
return fn.get | ||
} | ||
function hasOwnProperty (object, property) { | ||
return Object.prototype.hasOwnProperty.call(object, property) | ||
} | ||
function isComputedLazy (item) { | ||
return item.hasOwnProperty('lazy') && item.lazy | ||
return hasOwnProperty(item, 'lazy') && item.lazy | ||
} | ||
@@ -152,2 +169,3 @@ | ||
}; | ||
function handleAsyncComputedPropetyChanges (vm, key, pluginOptions, Vue) { | ||
@@ -190,3 +208,5 @@ let promiseId = 0; | ||
update: () => { | ||
watcher(getterOnly(vm.$options.asyncComputed[key]).apply(vm)); | ||
if (!vm._isDestroyed) { | ||
watcher(getterOnly(vm.$options.asyncComputed[key]).apply(vm)); | ||
} | ||
} | ||
@@ -219,15 +239,2 @@ }); | ||
function setAsyncState (vm, stateObject, state) { | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'state', state); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'updating', state === 'updating'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'error', state === 'error'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'success', state === 'success'); | ||
} | ||
function getterOnly (fn) { | ||
if (typeof fn === 'function') return fn | ||
return fn.get | ||
} | ||
function getterFn (key, fn) { | ||
@@ -238,7 +245,7 @@ if (typeof fn === 'function') return fn | ||
if (fn.hasOwnProperty('watch')) { | ||
if (hasOwnProperty(fn, 'watch')) { | ||
getter = getWatchedGetter(fn); | ||
} | ||
if (fn.hasOwnProperty('shouldUpdate')) { | ||
if (hasOwnProperty(fn, 'shouldUpdate')) { | ||
getter = getGetterWithShouldUpdate(fn, getter); | ||
@@ -284,2 +291,2 @@ } | ||
})); | ||
}))); |
@@ -8,4 +8,21 @@ 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 setAsyncState(vm, stateObject, state) { | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'state', state); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'updating', state === 'updating'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'error', state === 'error'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'success', state === 'success'); | ||
} | ||
function getterOnly(fn) { | ||
if (typeof fn === 'function') return fn; | ||
return fn.get; | ||
} | ||
function hasOwnProperty(object, property) { | ||
return Object.prototype.hasOwnProperty.call(object, property); | ||
} | ||
function isComputedLazy(item) { | ||
return item.hasOwnProperty('lazy') && item.lazy; | ||
return hasOwnProperty(item, 'lazy') && item.lazy; | ||
} | ||
@@ -156,2 +173,3 @@ | ||
}; | ||
function handleAsyncComputedPropetyChanges(vm, key, pluginOptions, Vue) { | ||
@@ -192,3 +210,5 @@ var promiseId = 0; | ||
update: function update() { | ||
watcher(getterOnly(vm.$options.asyncComputed[key]).apply(vm)); | ||
if (!vm._isDestroyed) { | ||
watcher(getterOnly(vm.$options.asyncComputed[key]).apply(vm)); | ||
} | ||
} | ||
@@ -219,15 +239,2 @@ }); | ||
function setAsyncState(vm, stateObject, state) { | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'state', state); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'updating', state === 'updating'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'error', state === 'error'); | ||
vm.$set(vm.$data._asyncComputed[stateObject], 'success', state === 'success'); | ||
} | ||
function getterOnly(fn) { | ||
if (typeof fn === 'function') return fn; | ||
return fn.get; | ||
} | ||
function getterFn(key, fn) { | ||
@@ -238,7 +245,7 @@ if (typeof fn === 'function') return fn; | ||
if (fn.hasOwnProperty('watch')) { | ||
if (hasOwnProperty(fn, 'watch')) { | ||
getter = getWatchedGetter(fn); | ||
} | ||
if (fn.hasOwnProperty('shouldUpdate')) { | ||
if (hasOwnProperty(fn, 'shouldUpdate')) { | ||
getter = getGetterWithShouldUpdate(fn, getter); | ||
@@ -245,0 +252,0 @@ } |
{ | ||
"name": "vue-async-computed", | ||
"version": "3.7.0", | ||
"version": "3.8.0", | ||
"description": "Async computed properties for Vue", | ||
"main": "dist/vue-async-computed.js", | ||
"module": "dist/vue-async-computed.esm.js", | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
@@ -14,6 +15,5 @@ "bin/", | ||
"lint": "eslint src test", | ||
"check": "npm run lint -s && dependency-check package.json --no-default-entries src/index.js", | ||
"watch": "watch 'npm run build' src test", | ||
"test": "babel-node --presets env test/index.js | tspec", | ||
"prebuild": "npm run check -s && npm run clean -s && mkdirp dist", | ||
"prebuild": "npm run lint -s && npm run clean -s && mkdirp dist", | ||
"build": "npm run rollup -s && npm run babel -s", | ||
@@ -60,20 +60,19 @@ "rollup-esm": "rollup src/index.js --output.format esm --name AsyncComputed --output.file dist/vue-async-computed.esm.esnext.js", | ||
"babel-core": "^6.26.3", | ||
"babel-eslint": "^10.0.1", | ||
"babel-eslint": "^10.0.2", | ||
"babel-istanbul": "^0.12.2", | ||
"babel-preset-env": "^1.7.0", | ||
"coveralls": "^3.0.3", | ||
"dependency-check": "^3.3.0", | ||
"coveralls": "^3.0.4", | ||
"doctoc": "^1.4.0", | ||
"eslint": "^5.16.0", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-import": "^2.17.3", | ||
"eslint-plugin-node": "^9.1.0", | ||
"eslint-plugin-promise": "^4.1.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-standard": "^14.1.0", | ||
"eslint-plugin-import": "^2.19.1", | ||
"eslint-plugin-node": "^10.0.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"estraverse-fb": "^1.3.2", | ||
"mkdirp": "^0.5.1", | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.14.0", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^1.27.14", | ||
"tap-spec": "^5.0.0", | ||
"tape": "^4.10.2", | ||
"tape": "^4.12.0", | ||
"vue": "^2.5.21", | ||
@@ -80,0 +79,0 @@ "watch": "^1.0.2" |
@@ -103,3 +103,3 @@ <big><h1 align="center">vue-async-computed</h1></big> | ||
--> | ||
<script src="https://unpkg.com/vue-async-computed@3.7.0"></script> | ||
<script src="https://unpkg.com/vue-async-computed@3.8.0"></script> | ||
``` | ||
@@ -106,0 +106,0 @@ |
53225
21
950