Merge branch 'master' into develop

This commit is contained in:
Jan Prochazka
2022-07-14 21:26:07 +02:00
24 changed files with 837 additions and 241 deletions

View File

@@ -56,8 +56,8 @@ export default {
y: 89,
z: 90,
leftWindowKey: 91,
rightWindowKey: 92,
selectKey: 93,
rightWindowKey: 93,
// selectKey: 93,
numPad0: 96,
numPad1: 97,
numPad2: 98,

View File

@@ -189,25 +189,29 @@ async function getCore(loader, args) {
function useCore(loader, args) {
const { url, params, reloadTrigger, transform, onLoaded } = loader(args);
const cacheKey = stableStringify({ url, ...params });
let closed = false;
let openedCount = 0;
return {
subscribe: onChange => {
async function handleReload() {
const res = await getCore(loader, args);
if (!closed) {
if (openedCount > 0) {
onChange(res);
}
}
openedCount += 1;
handleReload();
if (reloadTrigger) {
subscribeCacheChange(reloadTrigger, cacheKey, handleReload);
return () => {
closed = true;
openedCount -= 1;
unsubscribeCacheChange(reloadTrigger, cacheKey, handleReload);
};
} else {
return () => {
openedCount -= 1;
};
}
},
};