Skip to content

Commit

Permalink
feat (individual presenter): add support for external .html templates
Browse files Browse the repository at this point in the history
  • Loading branch information
karpovr committed May 13, 2021
1 parent e59c858 commit 436cd16
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions source-web/js/common/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,21 @@ browserBackend.uploadFile = function (params, tries) {
});
};

browserBackend.loadFile = function (url) {
const memoize = (fn) => {
const cache = {};
return (...args) => {
const n = args[0];
if (n in cache) {
return cache[n];
} else {
const result = fn(n);
cache[n] = result;
return result;
}
};
};

browserBackend.loadFile = memoize(function (url) {
return new Promise(function (resolve, reject) {
const done = () => {
if (xhr.status === 200) {
Expand All @@ -913,7 +927,7 @@ browserBackend.loadFile = function (url) {
xhr.ontimeout = fail;
xhr.send();
});
};
});

// //////////////////////////////////////////////////////////////////////

Expand Down

0 comments on commit 436cd16

Please sign in to comment.