chore: v3.0.0-beta.18
This commit is contained in:
Vendored
+14
-123
@@ -1,116 +1,5 @@
|
||||
/* eslint-disable no-undefined,no-param-reassign,no-shadow */
|
||||
|
||||
/**
|
||||
* Throttle execution of a function. Especially useful for rate limiting
|
||||
* execution of handlers on events like resize and scroll.
|
||||
*
|
||||
* @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
||||
* @param {Boolean} noTrailing Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the
|
||||
* throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time
|
||||
* after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,
|
||||
* the internal counter is reset)
|
||||
* @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
|
||||
* to `callback` when the throttled-function is executed.
|
||||
* @param {Boolean} debounceMode If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),
|
||||
* schedule `callback` to execute after `delay` ms.
|
||||
*
|
||||
* @return {Function} A new, throttled, function.
|
||||
*/
|
||||
var throttle = function ( delay, noTrailing, callback, debounceMode ) {
|
||||
|
||||
// After wrapper has stopped being called, this timeout ensures that
|
||||
// `callback` is executed at the proper times in `throttle` and `end`
|
||||
// debounce modes.
|
||||
var timeoutID;
|
||||
|
||||
// Keep track of the last time `callback` was executed.
|
||||
var lastExec = 0;
|
||||
|
||||
// `noTrailing` defaults to falsy.
|
||||
if ( typeof noTrailing !== 'boolean' ) {
|
||||
debounceMode = callback;
|
||||
callback = noTrailing;
|
||||
noTrailing = undefined;
|
||||
}
|
||||
|
||||
// The `wrapper` function encapsulates all of the throttling / debouncing
|
||||
// functionality and when executed will limit the rate at which `callback`
|
||||
// is executed.
|
||||
function wrapper () {
|
||||
|
||||
var self = this;
|
||||
var elapsed = Number(new Date()) - lastExec;
|
||||
var args = arguments;
|
||||
|
||||
// Execute `callback` and update the `lastExec` timestamp.
|
||||
function exec () {
|
||||
lastExec = Number(new Date());
|
||||
callback.apply(self, args);
|
||||
}
|
||||
|
||||
// If `debounceMode` is true (at begin) this is used to clear the flag
|
||||
// to allow future `callback` executions.
|
||||
function clear () {
|
||||
timeoutID = undefined;
|
||||
}
|
||||
|
||||
if ( debounceMode && !timeoutID ) {
|
||||
// Since `wrapper` is being called for the first time and
|
||||
// `debounceMode` is true (at begin), execute `callback`.
|
||||
exec();
|
||||
}
|
||||
|
||||
// Clear any existing timeout.
|
||||
if ( timeoutID ) {
|
||||
clearTimeout(timeoutID);
|
||||
}
|
||||
|
||||
if ( debounceMode === undefined && elapsed > delay ) {
|
||||
// In throttle mode, if `delay` time has been exceeded, execute
|
||||
// `callback`.
|
||||
exec();
|
||||
|
||||
} else if ( noTrailing !== true ) {
|
||||
// In trailing throttle mode, since `delay` time has not been
|
||||
// exceeded, schedule `callback` to execute `delay` ms after most
|
||||
// recent execution.
|
||||
//
|
||||
// If `debounceMode` is true (at begin), schedule `clear` to execute
|
||||
// after `delay` ms.
|
||||
//
|
||||
// If `debounceMode` is false (at end), schedule `callback` to
|
||||
// execute after `delay` ms.
|
||||
timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return the wrapper function.
|
||||
return wrapper;
|
||||
|
||||
};
|
||||
|
||||
/* eslint-disable no-undefined */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Debounce execution of a function. Debouncing, unlike throttling,
|
||||
* guarantees that a function is only executed a single time, either at the
|
||||
* very beginning of a series of calls, or at the very end.
|
||||
*
|
||||
* @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
||||
* @param {Boolean} atBegin Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds
|
||||
* after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.
|
||||
* (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).
|
||||
* @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
|
||||
* to `callback` when the debounced-function is executed.
|
||||
*
|
||||
* @return {Function} A new, debounced function.
|
||||
*/
|
||||
var debounce = function ( delay, atBegin, callback ) {
|
||||
return callback === undefined ? throttle(delay, atBegin, false) : throttle(delay, callback, atBegin !== false);
|
||||
};
|
||||
import oThrottle from 'throttle-debounce/throttle';
|
||||
import oDebounce from 'throttle-debounce/debounce';
|
||||
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
||||
return typeof obj;
|
||||
@@ -316,9 +205,9 @@ function factory(action) {
|
||||
};
|
||||
}
|
||||
|
||||
var throttle$2 = factory(throttle);
|
||||
var throttle = factory(oThrottle);
|
||||
|
||||
var debounce$1 = factory(debounce);
|
||||
var debounce = factory(oDebounce);
|
||||
|
||||
function getMergedDefinition(def) {
|
||||
return Globals.Vue.util.mergeOptions({}, def);
|
||||
@@ -451,8 +340,8 @@ var SmartApollo = function () {
|
||||
// GraphQL Variables
|
||||
if (typeof this.options.variables === 'function') {
|
||||
var _cb = this.executeApollo.bind(this);
|
||||
_cb = this.options.throttle ? throttle$2(_cb, this.options.throttle) : _cb;
|
||||
_cb = this.options.debounce ? debounce$1(_cb, this.options.debounce) : _cb;
|
||||
_cb = this.options.throttle ? throttle(_cb, this.options.throttle) : _cb;
|
||||
_cb = this.options.debounce ? debounce(_cb, this.options.debounce) : _cb;
|
||||
this._watchers.push(this.vm.$watch(function () {
|
||||
return _this.options.variables.call(_this.vm);
|
||||
}, _cb, {
|
||||
@@ -1566,9 +1455,9 @@ var CApolloQuery = {
|
||||
data: null,
|
||||
loading: false,
|
||||
networkStatus: 7,
|
||||
error: null,
|
||||
times: 0
|
||||
}
|
||||
error: null
|
||||
},
|
||||
times: 0
|
||||
};
|
||||
},
|
||||
|
||||
@@ -1646,10 +1535,11 @@ var CApolloQuery = {
|
||||
data: isDataFilled(data) ? data : undefined,
|
||||
loading: loading,
|
||||
error: error,
|
||||
networkStatus: networkStatus,
|
||||
times: ++this.$_times
|
||||
networkStatus: networkStatus
|
||||
};
|
||||
|
||||
this.times = ++this.$_times;
|
||||
|
||||
this.$emit('result', this.result);
|
||||
},
|
||||
error: function error(_error) {
|
||||
@@ -1678,6 +1568,7 @@ var CApolloQuery = {
|
||||
render: function render(h) {
|
||||
var result = this.$scopedSlots.default({
|
||||
result: this.result,
|
||||
times: this.times,
|
||||
query: this.$apollo.queries.query,
|
||||
isLoading: this.$apolloData.loading,
|
||||
gqlError: this.result && this.result.error && this.result.error.gqlError
|
||||
@@ -2025,7 +1916,7 @@ function install(Vue, options) {
|
||||
ApolloProvider.install = install;
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
ApolloProvider.version = "3.0.0-beta.17";
|
||||
ApolloProvider.version = "3.0.0-beta.18";
|
||||
|
||||
// Apollo provider
|
||||
var ApolloProvider$1 = ApolloProvider;
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+18
-127
@@ -1,122 +1,11 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(factory((global['vue-apollo'] = {})));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('throttle-debounce/throttle'), require('throttle-debounce/debounce')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', 'throttle-debounce/throttle', 'throttle-debounce/debounce'], factory) :
|
||||
(factory((global['vue-apollo'] = {}),global.oThrottle,global.oDebounce));
|
||||
}(this, (function (exports,oThrottle,oDebounce) { 'use strict';
|
||||
|
||||
/* eslint-disable no-undefined,no-param-reassign,no-shadow */
|
||||
|
||||
/**
|
||||
* Throttle execution of a function. Especially useful for rate limiting
|
||||
* execution of handlers on events like resize and scroll.
|
||||
*
|
||||
* @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
||||
* @param {Boolean} noTrailing Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the
|
||||
* throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time
|
||||
* after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,
|
||||
* the internal counter is reset)
|
||||
* @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
|
||||
* to `callback` when the throttled-function is executed.
|
||||
* @param {Boolean} debounceMode If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),
|
||||
* schedule `callback` to execute after `delay` ms.
|
||||
*
|
||||
* @return {Function} A new, throttled, function.
|
||||
*/
|
||||
var throttle = function ( delay, noTrailing, callback, debounceMode ) {
|
||||
|
||||
// After wrapper has stopped being called, this timeout ensures that
|
||||
// `callback` is executed at the proper times in `throttle` and `end`
|
||||
// debounce modes.
|
||||
var timeoutID;
|
||||
|
||||
// Keep track of the last time `callback` was executed.
|
||||
var lastExec = 0;
|
||||
|
||||
// `noTrailing` defaults to falsy.
|
||||
if ( typeof noTrailing !== 'boolean' ) {
|
||||
debounceMode = callback;
|
||||
callback = noTrailing;
|
||||
noTrailing = undefined;
|
||||
}
|
||||
|
||||
// The `wrapper` function encapsulates all of the throttling / debouncing
|
||||
// functionality and when executed will limit the rate at which `callback`
|
||||
// is executed.
|
||||
function wrapper () {
|
||||
|
||||
var self = this;
|
||||
var elapsed = Number(new Date()) - lastExec;
|
||||
var args = arguments;
|
||||
|
||||
// Execute `callback` and update the `lastExec` timestamp.
|
||||
function exec () {
|
||||
lastExec = Number(new Date());
|
||||
callback.apply(self, args);
|
||||
}
|
||||
|
||||
// If `debounceMode` is true (at begin) this is used to clear the flag
|
||||
// to allow future `callback` executions.
|
||||
function clear () {
|
||||
timeoutID = undefined;
|
||||
}
|
||||
|
||||
if ( debounceMode && !timeoutID ) {
|
||||
// Since `wrapper` is being called for the first time and
|
||||
// `debounceMode` is true (at begin), execute `callback`.
|
||||
exec();
|
||||
}
|
||||
|
||||
// Clear any existing timeout.
|
||||
if ( timeoutID ) {
|
||||
clearTimeout(timeoutID);
|
||||
}
|
||||
|
||||
if ( debounceMode === undefined && elapsed > delay ) {
|
||||
// In throttle mode, if `delay` time has been exceeded, execute
|
||||
// `callback`.
|
||||
exec();
|
||||
|
||||
} else if ( noTrailing !== true ) {
|
||||
// In trailing throttle mode, since `delay` time has not been
|
||||
// exceeded, schedule `callback` to execute `delay` ms after most
|
||||
// recent execution.
|
||||
//
|
||||
// If `debounceMode` is true (at begin), schedule `clear` to execute
|
||||
// after `delay` ms.
|
||||
//
|
||||
// If `debounceMode` is false (at end), schedule `callback` to
|
||||
// execute after `delay` ms.
|
||||
timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return the wrapper function.
|
||||
return wrapper;
|
||||
|
||||
};
|
||||
|
||||
/* eslint-disable no-undefined */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Debounce execution of a function. Debouncing, unlike throttling,
|
||||
* guarantees that a function is only executed a single time, either at the
|
||||
* very beginning of a series of calls, or at the very end.
|
||||
*
|
||||
* @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
||||
* @param {Boolean} atBegin Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds
|
||||
* after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.
|
||||
* (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).
|
||||
* @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
|
||||
* to `callback` when the debounced-function is executed.
|
||||
*
|
||||
* @return {Function} A new, debounced function.
|
||||
*/
|
||||
var debounce = function ( delay, atBegin, callback ) {
|
||||
return callback === undefined ? throttle(delay, atBegin, false) : throttle(delay, callback, atBegin !== false);
|
||||
};
|
||||
oThrottle = oThrottle && oThrottle.hasOwnProperty('default') ? oThrottle['default'] : oThrottle;
|
||||
oDebounce = oDebounce && oDebounce.hasOwnProperty('default') ? oDebounce['default'] : oDebounce;
|
||||
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
||||
return typeof obj;
|
||||
@@ -322,9 +211,9 @@ function factory(action) {
|
||||
};
|
||||
}
|
||||
|
||||
var throttle$2 = factory(throttle);
|
||||
var throttle = factory(oThrottle);
|
||||
|
||||
var debounce$1 = factory(debounce);
|
||||
var debounce = factory(oDebounce);
|
||||
|
||||
function getMergedDefinition(def) {
|
||||
return Globals.Vue.util.mergeOptions({}, def);
|
||||
@@ -457,8 +346,8 @@ var SmartApollo = function () {
|
||||
// GraphQL Variables
|
||||
if (typeof this.options.variables === 'function') {
|
||||
var _cb = this.executeApollo.bind(this);
|
||||
_cb = this.options.throttle ? throttle$2(_cb, this.options.throttle) : _cb;
|
||||
_cb = this.options.debounce ? debounce$1(_cb, this.options.debounce) : _cb;
|
||||
_cb = this.options.throttle ? throttle(_cb, this.options.throttle) : _cb;
|
||||
_cb = this.options.debounce ? debounce(_cb, this.options.debounce) : _cb;
|
||||
this._watchers.push(this.vm.$watch(function () {
|
||||
return _this.options.variables.call(_this.vm);
|
||||
}, _cb, {
|
||||
@@ -1572,9 +1461,9 @@ var CApolloQuery = {
|
||||
data: null,
|
||||
loading: false,
|
||||
networkStatus: 7,
|
||||
error: null,
|
||||
times: 0
|
||||
}
|
||||
error: null
|
||||
},
|
||||
times: 0
|
||||
};
|
||||
},
|
||||
|
||||
@@ -1652,10 +1541,11 @@ var CApolloQuery = {
|
||||
data: isDataFilled(data) ? data : undefined,
|
||||
loading: loading,
|
||||
error: error,
|
||||
networkStatus: networkStatus,
|
||||
times: ++this.$_times
|
||||
networkStatus: networkStatus
|
||||
};
|
||||
|
||||
this.times = ++this.$_times;
|
||||
|
||||
this.$emit('result', this.result);
|
||||
},
|
||||
error: function error(_error) {
|
||||
@@ -1684,6 +1574,7 @@ var CApolloQuery = {
|
||||
render: function render(h) {
|
||||
var result = this.$scopedSlots.default({
|
||||
result: this.result,
|
||||
times: this.times,
|
||||
query: this.$apollo.queries.query,
|
||||
isLoading: this.$apolloData.loading,
|
||||
gqlError: this.result && this.result.error && this.result.error.gqlError
|
||||
@@ -2031,7 +1922,7 @@ function install(Vue, options) {
|
||||
ApolloProvider.install = install;
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
ApolloProvider.version = "3.0.0-beta.17";
|
||||
ApolloProvider.version = "3.0.0-beta.18";
|
||||
|
||||
// Apollo provider
|
||||
var ApolloProvider$1 = ApolloProvider;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-apollo",
|
||||
"version": "3.0.0-beta.17",
|
||||
"version": "3.0.0-beta.18",
|
||||
"description": "Use Apollo and GraphQL with Vue.js",
|
||||
"main": "dist/vue-apollo.umd.js",
|
||||
"module": "dist/vue-apollo.esm.js",
|
||||
|
||||
Reference in New Issue
Block a user