angular-es-utils
Advanced tools
Comparing version 1.2.28 to 1.2.29
@@ -6,11 +6,13 @@ 'use strict'; | ||
}); | ||
/** | ||
* @author Kuitos | ||
* @homepage https://github.com/kuitos/ | ||
* @since 2016-04-12 | ||
*/ | ||
var _injector = require('../injector'); | ||
var _injector2 = _interopRequireDefault(_injector); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = function () { | ||
var delay = arguments.length <= 0 || arguments[0] === undefined ? 300 : arguments[0]; | ||
var context = arguments[1]; | ||
var invokeApply = arguments[2]; | ||
return function (target, name, descriptor) { | ||
@@ -23,3 +25,4 @@ | ||
var fn = descriptor.value || target[name]; | ||
var timer = null; | ||
var pendingDebounce = null; | ||
var $timeout = _injector2.default.get('$timeout'); | ||
@@ -33,8 +36,8 @@ descriptor.value = function () { | ||
clearTimeout(timer); | ||
$timeout.cancel(pendingDebounce); | ||
timer = setTimeout(function () { | ||
timer = null; | ||
pendingDebounce = $timeout(function () { | ||
pendingDebounce = null; | ||
fn.apply(context || _this, args); | ||
}, delay); | ||
}, delay, invokeApply); | ||
}; | ||
@@ -44,2 +47,6 @@ | ||
}; | ||
}; | ||
}; /** | ||
* @author Kuitos | ||
* @homepage https://github.com/kuitos/ | ||
* @since 2016-04-12 | ||
*/ |
{ | ||
"name": "angular-es-utils", | ||
"version": "1.2.28", | ||
"version": "1.2.29", | ||
"description": "es utils design for angular1.x", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -6,3 +6,11 @@ 'use strict'; | ||
}); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /** | ||
* @author Kuitos | ||
* @homepage https://github.com/kuitos/ | ||
* @since 2016-05-11 | ||
*/ | ||
exports.setApiPrefix = setApiPrefix; | ||
exports.setCommonConfigs = setCommonConfigs; | ||
@@ -17,9 +25,4 @@ require('angular-resource'); | ||
/** | ||
* @author Kuitos | ||
* @homepage https://github.com/kuitos/ | ||
* @since 2016-05-11 | ||
*/ | ||
var apiPrefix = ''; | ||
var commonConfigs = {}; | ||
@@ -30,21 +33,29 @@ function setApiPrefix(prefix) { | ||
function setCommonConfigs(cc) { | ||
commonConfigs = cc; | ||
} | ||
exports.default = function (url, cache, params, additionalActions) { | ||
var additionalConfigs = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; | ||
additionalConfigs = _extends({}, commonConfigs, additionalConfigs); | ||
// 默认cache为defaultRestCache | ||
// 自定义配置(配合$http interceptor) saveStatus:该操作将维护一个保存状态 | ||
// 自定义配置(配合$http interceptor) | ||
var DEFAULT_ACTIONS = { | ||
// 查询,结果为对象 | ||
'get': { method: 'GET', cache: cache }, | ||
'get': _extends({ method: 'GET', cache: cache }, additionalConfigs), | ||
// 查询,结果为数组 | ||
'query': { method: 'GET', isArray: true, cache: cache }, | ||
'query': _extends({ method: 'GET', isArray: true, cache: cache }, additionalConfigs), | ||
// 保存(新增) | ||
'save': { method: 'POST', cache: cache }, | ||
'save': _extends({ method: 'POST', cache: cache }, additionalConfigs), | ||
// 修改(全量) | ||
'update': { method: 'PUT', cache: cache }, | ||
'update': _extends({ method: 'PUT', cache: cache }, additionalConfigs), | ||
// 修改(部分) | ||
'patch': { method: 'PATCH', cache: cache }, | ||
'patch': _extends({ method: 'PATCH', cache: cache }, additionalConfigs), | ||
// 逻辑删除 | ||
'remove': { method: 'DELETE', cache: cache }, | ||
'remove': _extends({ method: 'DELETE', cache: cache }, additionalConfigs), | ||
// 物理删除 | ||
'delete': { method: 'DELETE', cache: cache } | ||
'delete': _extends({ method: 'DELETE', cache: cache }, additionalConfigs) | ||
}; | ||
@@ -51,0 +62,0 @@ |
25915
581