Skip to content

Commit

Permalink
Update working memoize!!!!!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
sonrisacc committed Jan 26, 2018
1 parent 7e603f6 commit 2cad38e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/helper/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ const memoize = fun => {
let cache = [];
return input => {
if (cache[input] !== undefined) return cache[input];
fun(input).then(res => {
cache[input] = res;
return cache[input];
});
cache[input] = fun(input);
return cache[input];
};
};

Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const outputField = document.querySelector('input[name=response]');
const inputString = document.querySelector('input[name=request]');

const updateInputField = () => {
let res = postRequest(inputString.value);

outputField.value = res;
inputString.value = '';
postRequest(inputString.value).then(res => {
outputField.value = res.body;
inputString.value = '';
});
};

const changeDisplayMsg = () => {
Expand Down

0 comments on commit 2cad38e

Please sign in to comment.