Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prop updateImmediately to FormsyText #103

Merged

Conversation

codeaholicguy
Copy link
Collaborator

I added prop updateImmediately to FormsyText in case someone want to get status valid or invalid of textbox immediately when user fill in.

Usage

<FormsyText
  name='name'
  updateImmediately
/>

@krizka
Copy link

krizka commented May 30, 2016

Updating on every change is slow for text inputs. Need to add some debouncing here.

@codeaholicguy
Copy link
Collaborator Author

@krizka good idea

@krizka
Copy link

krizka commented May 30, 2016

Please, look at my gist in comments to #97

@codeaholicguy
Copy link
Collaborator Author

codeaholicguy commented May 30, 2016

@krizka Nice, I added debounce for solving performance issue with calling setValue continuously

@krizka
Copy link

krizka commented May 30, 2016

We can not call debounce every time we want to change, but have to get a function from debounce and call it many times. That is why I making setValidate method only once on component mount.

@codeaholicguy
Copy link
Collaborator Author

that why I created this.changeValue

if (this.props.updateImmediately) {
  if (this.changeValue) {
    this.changeValue(event.currentTarget.value);
  } else {
    this.changeValue = debounce(this.setValue, 200);
    this.changeValue(event.currentTarget.value);
  }
}

@krizka
Copy link

krizka commented May 30, 2016

Oh, sorry, now I got it. Nice job)
To be more clear and dry, maybe.

if (!this.changeValue)
  this.changeValue = debounce(this.setValue, 200);

this.changeValue(event.currentTarget.value);

@codeaholicguy
Copy link
Collaborator Author

great, thank you for you feedback

@mbrookes
Copy link
Collaborator

mbrookes commented Jun 6, 2016

Please check out #109.

@mbrookes mbrookes merged commit 4ef563a into formsy:master Sep 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants