Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/react-query/es/core/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
import { difference, replaceAt } from './utils';
import { notifyManager } from './notifyManager';
import { QueryObserver } from './queryObserver';
import { Subscribable } from './subscribable';
export var QueriesObserver = /*#__PURE__*/function (_Subscribable) {
_inheritsLoose(QueriesObserver, _Subscribable);
function QueriesObserver(client, queries) {
var _this;
_this = _Subscribable.call(this) || this;
_this.client = client;
_this.queries = [];
_this.result = [];
_this.observers = [];
_this.observersMap = {};
if (queries) {
_this.setQueries(queries);
}
return _this;
}
var _proto = QueriesObserver.prototype;
_proto.onSubscribe = function onSubscribe() {
var _this2 = this;
if (this.listeners.length === 1) {
this.observers.forEach(function (observer) {
observer.subscribe(function (result) {
_this2.onUpdate(observer, result);
});
});
}
};
_proto.onUnsubscribe = function onUnsubscribe() {
if (!this.listeners.length) {
this.destroy();
}
};
_proto.destroy = function destroy() {
this.listeners = [];
this.observers.forEach(function (observer) {
observer.destroy();
});
};
_proto.setQueries = function setQueries(queries, notifyOptions) {
this.queries = queries;
this.updateObservers(notifyOptions);
};
_proto.getCurrentResult = function getCurrentResult() {
return this.result;
};
_proto.getOptimisticResult = function getOptimisticResult(queries) {
var _this3 = this;
return queries.map(function (options) {
var defaultedOptions = _this3.client.defaultQueryObserverOptions(options);
return _this3.getObserver(defaultedOptions).getOptimisticResult(defaultedOptions);
});
};
_proto.getObserver = function getObserver(options) {
var defaultedOptions = this.client.defaultQueryObserverOptions(options);
return this.observersMap[defaultedOptions.queryHash] || new QueryObserver(this.client, defaultedOptions);
};
_proto.updateObservers = function updateObservers(notifyOptions) {
var _this4 = this;
notifyManager.batch(function () {
var hasIndexChange = false;
var prevObservers = _this4.observers;
var prevOberversMap = _this4.observersMap;
var newResult = [];
var newObservers = [];
var newObserversMap = {};
_this4.queries.forEach(function (options, i) {
var defaultedOptions = _this4.client.defaultQueryObserverOptions(options);
var queryHash = defaultedOptions.queryHash;
var observer = _this4.getObserver(defaultedOptions);
if (prevOberversMap[queryHash]) {
observer.setOptions(defaultedOptions, notifyOptions);
}
if (observer !== prevObservers[i]) {
hasIndexChange = true;
}
newObservers.push(observer);
newResult.push(observer.getCurrentResult());
newObserversMap[queryHash] = observer;
});
if (prevObservers.length === newObservers.length && !hasIndexChange) {
return;
}
_this4.observers = newObservers;
_this4.observersMap = newObserversMap;
_this4.result = newResult;
if (!_this4.hasListeners()) {
return;
}
difference(prevObservers, newObservers).forEach(function (observer) {
observer.destroy();
});
difference(newObservers, prevObservers).forEach(function (observer) {
observer.subscribe(function (result) {
_this4.onUpdate(observer, result);
});
});
_this4.notify();
});
};
_proto.onUpdate = function onUpdate(observer, result) {
var index = this.observers.indexOf(observer);
if (index !== -1) {
this.result = replaceAt(this.result, index, result);
this.notify();
}
};
_proto.notify = function notify() {
var _this5 = this;
notifyManager.batch(function () {
_this5.listeners.forEach(function (listener) {
listener(_this5.result);
});
});
};
return QueriesObserver;
}(Subscribable); |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0048 ]-- |