Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
This adds an optional 'debounceUpdate' parameter to the element to reduce spammy updates from the User in cases where a delayed update would be preferable.
  • Loading branch information
iainjreid committed Apr 4, 2017
1 parent 78f394d commit ba6e8c8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions iron-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@
observer: "_allowedPatternChanged"
},

/**
* Delay the updating of the bound value whilst the user is entering data. This property will accept a number as
* its input, which should be the number of milliseconds from which the users input should be debounced.
*/
debounceUpdate: {
type: Number
},

_previousValidInput: {
type: String,
value: ''
Expand Down Expand Up @@ -199,6 +207,15 @@
}
}

// If a `debounceUpdate` value has been supplied, delay the updating of the `bindValue` property
if (this.debounceUpdate) {
this.debounce('debouncedUpdateValue', this._updateValue.bind(this), this.debounceUpdate);
} else {
this._updateValue();
}
},

_updateValue: function() {
this.bindValue = this.value;
this._previousValidInput = this.value;
this._patternAlreadyChecked = false;
Expand Down

0 comments on commit ba6e8c8

Please sign in to comment.