From e80943ed85e7e46c140bc4e235185520932b0818 Mon Sep 17 00:00:00 2001 From: Steffan Date: Fri, 1 Jul 2016 10:10:04 +0200 Subject: [PATCH 1/2] support promise return value in response interceptor --- src/http/client/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/http/client/index.js b/src/http/client/index.js index 2a2d8682..3d995c16 100644 --- a/src/http/client/index.js +++ b/src/http/client/index.js @@ -30,25 +30,25 @@ export default function (context) { } function next(response) { - when(response, (response) => { - if (isFunction(response)) { + if (isFunction(response)) { - resHandlers.unshift(response); + resHandlers.unshift(response); - } else if (isObject(response)) { + } else if (isObject(response)) { - resHandlers.forEach((handler) => { - handler.call(context, response); + resHandlers.forEach((handler) => { + response = when(response, (response) => { + return handler.call(context, response) || response; }); + }); - resolve(response); + when(response, resolve); - return; - } + return; + } - exec(); - }); + exec(); } exec(); From 97a3125c3a28428dd0ff3de59a0e705b4065acb3 Mon Sep 17 00:00:00 2001 From: Steffan Date: Fri, 1 Jul 2016 10:19:36 +0200 Subject: [PATCH 2/2] v0.9.2 --- bower.json | 2 +- dist/vue-resource.common.js | 24 ++++++++++++------------ dist/vue-resource.es2015.js | 24 ++++++++++++------------ dist/vue-resource.js | 24 ++++++++++++------------ dist/vue-resource.min.js | 4 ++-- package.json | 6 +++--- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/bower.json b/bower.json index 35ff7208..c189373b 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "vue-resource", "main": "dist/vue-resource.js", "description": "A web request service for Vue.js", - "version": "0.9.1", + "version": "0.9.2", "homepage": "https://github.com/vuejs/vue-resource", "license": "MIT", "ignore": [ diff --git a/dist/vue-resource.common.js b/dist/vue-resource.common.js index 17e4f4e4..a120e190 100644 --- a/dist/vue-resource.common.js +++ b/dist/vue-resource.common.js @@ -1,5 +1,5 @@ /*! - * vue-resource v0.9.1 + * vue-resource v0.9.2 * https://github.com/vuejs/vue-resource * Released under the MIT License. */ @@ -1022,24 +1022,24 @@ function Client (context) { } function next(response) { - when(response, function (response) { - if (isFunction(response)) { + if (isFunction(response)) { - resHandlers.unshift(response); - } else if (isObject(response)) { + resHandlers.unshift(response); + } else if (isObject(response)) { - resHandlers.forEach(function (handler) { - handler.call(context, response); + resHandlers.forEach(function (handler) { + response = when(response, function (response) { + return handler.call(context, response) || response; }); + }); - resolve(response); + when(response, resolve); - return; - } + return; + } - exec(); - }); + exec(); } exec(); diff --git a/dist/vue-resource.es2015.js b/dist/vue-resource.es2015.js index a3a80cdc..3f9f70bb 100644 --- a/dist/vue-resource.es2015.js +++ b/dist/vue-resource.es2015.js @@ -1,5 +1,5 @@ /*! - * vue-resource v0.9.1 + * vue-resource v0.9.2 * https://github.com/vuejs/vue-resource * Released under the MIT License. */ @@ -1020,24 +1020,24 @@ function Client (context) { } function next(response) { - when(response, function (response) { - if (isFunction(response)) { + if (isFunction(response)) { - resHandlers.unshift(response); - } else if (isObject(response)) { + resHandlers.unshift(response); + } else if (isObject(response)) { - resHandlers.forEach(function (handler) { - handler.call(context, response); + resHandlers.forEach(function (handler) { + response = when(response, function (response) { + return handler.call(context, response) || response; }); + }); - resolve(response); + when(response, resolve); - return; - } + return; + } - exec(); - }); + exec(); } exec(); diff --git a/dist/vue-resource.js b/dist/vue-resource.js index 58497e89..3d9c8ebd 100644 --- a/dist/vue-resource.js +++ b/dist/vue-resource.js @@ -1,5 +1,5 @@ /*! - * vue-resource v0.9.1 + * vue-resource v0.9.2 * https://github.com/vuejs/vue-resource * Released under the MIT License. */ @@ -1026,24 +1026,24 @@ } function next(response) { - when(response, function (response) { - if (isFunction(response)) { + if (isFunction(response)) { - resHandlers.unshift(response); - } else if (isObject(response)) { + resHandlers.unshift(response); + } else if (isObject(response)) { - resHandlers.forEach(function (handler) { - handler.call(context, response); + resHandlers.forEach(function (handler) { + response = when(response, function (response) { + return handler.call(context, response) || response; }); + }); - resolve(response); + when(response, resolve); - return; - } + return; + } - exec(); - }); + exec(); } exec(); diff --git a/dist/vue-resource.min.js b/dist/vue-resource.min.js index e91267b7..96e29f63 100644 --- a/dist/vue-resource.min.js +++ b/dist/vue-resource.min.js @@ -1,7 +1,7 @@ /*! - * vue-resource v0.9.1 + * vue-resource v0.9.2 * https://github.com/vuejs/vue-resource * Released under the MIT License. */ -!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.VueResource=n()}(this,function(){"use strict";function t(t){this.state=Z,this.value=void 0,this.deferred=[];var n=this;try{t(function(t){n.resolve(t)},function(t){n.reject(t)})}catch(e){n.reject(e)}}function n(t,n){t instanceof nt?this.promise=t:this.promise=new nt(t.bind(n)),this.context=n}function e(t){rt=t.util,ot=t.config.debug||!t.config.silent}function o(t){"undefined"!=typeof console&&ot&&console.warn("[VueResource warn]: "+t)}function r(t){"undefined"!=typeof console&&console.error(t)}function i(t,n){return rt.nextTick(t,n)}function u(t){return t.replace(/^\s*|\s*$/g,"")}function s(t){return"string"==typeof t}function c(t){return t===!0||t===!1}function a(t){return"function"==typeof t}function f(t){return null!==t&&"object"==typeof t}function h(t){return f(t)&&Object.getPrototypeOf(t)==Object.prototype}function p(t){return"undefined"!=typeof FormData&&t instanceof FormData}function l(t,e,o){var r=n.resolve(t);return arguments.length<2?r:r.then(e,o)}function d(t,n,e){return e=e||{},a(e)&&(e=e.call(n)),v(t.bind({$vm:n,$options:e}),t,{$options:e})}function m(t,n){var e,o;if("number"==typeof t.length)for(e=0;e=200&&i<300}return t.prototype.text=function(){return this.body},t.prototype.blob=function(){return new Blob([this.body])},t.prototype.json=function(){return JSON.parse(this.body)},t}(),dt=function(){function t(n){pt(this,t),this.method="GET",this.body=null,this.params={},this.headers={},st(this,n)}return t.prototype.getUrl=function(){return R(this)},t.prototype.getBody=function(){return this.body},t.prototype.respondWith=function(t,n){return new lt(t,st(n||{},{url:this.getUrl()}))},t}(),mt={"X-Requested-With":"XMLHttpRequest"},vt={Accept:"application/json, text/plain, */*"},yt={"Content-Type":"application/json;charset=utf-8"};return V.options={},V.headers={put:yt,post:yt,patch:yt,"delete":yt,custom:mt,common:vt},V.interceptors=[D,X,J,L,N,M,H],["get","delete","head","jsonp"].forEach(function(t){V[t]=function(n,e){return this(st(e||{},{url:n,method:t}))}}),["post","put","patch"].forEach(function(t){V[t]=function(n,e,o){return this(st(o||{},{url:n,method:t,body:e}))}}),_.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},update:{method:"PUT"},remove:{method:"DELETE"},"delete":{method:"DELETE"}},"undefined"!=typeof window&&window.Vue&&window.Vue.use(K),K}); \ No newline at end of file +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.VueResource=n()}(this,function(){"use strict";function t(t){this.state=Z,this.value=void 0,this.deferred=[];var n=this;try{t(function(t){n.resolve(t)},function(t){n.reject(t)})}catch(e){n.reject(e)}}function n(t,n){t instanceof nt?this.promise=t:this.promise=new nt(t.bind(n)),this.context=n}function e(t){rt=t.util,ot=t.config.debug||!t.config.silent}function o(t){"undefined"!=typeof console&&ot&&console.warn("[VueResource warn]: "+t)}function r(t){"undefined"!=typeof console&&console.error(t)}function i(t,n){return rt.nextTick(t,n)}function u(t){return t.replace(/^\s*|\s*$/g,"")}function s(t){return"string"==typeof t}function c(t){return t===!0||t===!1}function a(t){return"function"==typeof t}function f(t){return null!==t&&"object"==typeof t}function h(t){return f(t)&&Object.getPrototypeOf(t)==Object.prototype}function p(t){return"undefined"!=typeof FormData&&t instanceof FormData}function l(t,e,o){var r=n.resolve(t);return arguments.length<2?r:r.then(e,o)}function d(t,n,e){return e=e||{},a(e)&&(e=e.call(n)),v(t.bind({$vm:n,$options:e}),t,{$options:e})}function m(t,n){var e,o;if("number"==typeof t.length)for(e=0;e=200&&i<300}return t.prototype.text=function(){return this.body},t.prototype.blob=function(){return new Blob([this.body])},t.prototype.json=function(){return JSON.parse(this.body)},t}(),dt=function(){function t(n){pt(this,t),this.method="GET",this.body=null,this.params={},this.headers={},st(this,n)}return t.prototype.getUrl=function(){return R(this)},t.prototype.getBody=function(){return this.body},t.prototype.respondWith=function(t,n){return new lt(t,st(n||{},{url:this.getUrl()}))},t}(),mt={"X-Requested-With":"XMLHttpRequest"},vt={Accept:"application/json, text/plain, */*"},yt={"Content-Type":"application/json;charset=utf-8"};return V.options={},V.headers={put:yt,post:yt,patch:yt,"delete":yt,custom:mt,common:vt},V.interceptors=[D,X,J,L,N,M,H],["get","delete","head","jsonp"].forEach(function(t){V[t]=function(n,e){return this(st(e||{},{url:n,method:t}))}}),["post","put","patch"].forEach(function(t){V[t]=function(n,e,o){return this(st(o||{},{url:n,method:t,body:e}))}}),_.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},update:{method:"PUT"},remove:{method:"DELETE"},"delete":{method:"DELETE"}},"undefined"!=typeof window&&window.Vue&&window.Vue.use(K),K}); \ No newline at end of file diff --git a/package.json b/package.json index 0fde1309..24249e8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-resource", - "version": "0.9.1", + "version": "0.9.2", "description": "A web request service for Vue.js", "main": "dist/vue-resource.common.js", "jsnext:main": "dist/vue-resource.es2015.js", @@ -24,7 +24,7 @@ }, "homepage": "https://github.com/vuejs/vue-resource#readme", "devDependencies": { - "babel-core": "^6.9.1", + "babel-core": "^6.10.4", "babel-loader": "^6.2.4", "babel-plugin-transform-runtime": "^6.9.0", "babel-preset-es2015-loose": "^7.0.0", @@ -34,7 +34,7 @@ "rollup": "^0.33.0", "rollup-plugin-babel": "^2.6.1", "uglify-js": "^2.6.4", - "vue": "^1.0.25", + "vue": "^1.0.26", "webpack": "^1.13.1" } }