revised comments

This commit is contained in:
Ben Wheeler 2019-09-27 12:21:41 -04:00
parent 0d4d6a9adc
commit 3bc6e7ff6f

View file

@ -34,7 +34,8 @@ class UsernameStep extends React.Component {
focused: null,
showPassword: false
};
// keeps us from submitting multiple remote requests for a single username
// simple object to memoize remote requests for usernames.
// keeps us from submitting multiple requests for same data.
this.usernameRemoteCache = {};
}
componentDidMount () {
@ -52,6 +53,7 @@ class UsernameStep extends React.Component {
handleSetUsernameRef (usernameInputRef) {
this.usernameInput = usernameInputRef;
}
// simple function to memoize remote requests for usernames
validateUsernameRemotelyWithCache (username) {
if (this.usernameRemoteCache.hasOwnProperty(username)) {
return Promise.resolve(this.usernameRemoteCache[username]);