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

Minor doc fixes. #4557

Merged
merged 3 commits into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/elements/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@

/**
* The name of the variable to add to the binding scope with the index
* for the inst. If `sort` is provided, the index will reflect the
* sorted order (rather than the original array order).
* of the instance in the sorted and filtered list of rendered items.
* Note, for the index in the `this.items` array, use the value of the
* `itemsIndexAs` property.
*/
indexAs: {
type: String,
Expand All @@ -167,8 +168,9 @@

/**
* The name of the variable to add to the binding scope with the index
* for the inst. If `sort` is provided, the index will reflect the
* sorted order (rather than the original array order).
* of the instance in the `this.items` array. Note, for the index of
* this instance in the sorted and filtered list of rendered items,
* use the value of the `indexAs` property.
*/
itemsIndexAs: {
type: String,
Expand Down
14 changes: 13 additions & 1 deletion lib/utils/debounce.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@
}
/**
* Creates a debouncer if no debouncer is passed as a parameter
* or it cancels an active debouncer otherwise.
* or it cancels an active debouncer otherwise. For example, the following
* code can be called multiple times within a microtask and the provided
* function will be debounced (called once at the next microtask checkpoint):
*
* let job = Polymer.Debouncer.debounce(job, Polymer.Async.microTask, () => {
* console.log('debounced!');
* });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it important for the value of job to be preserved across multiple calls here? If I copy this code into an event handler, will it debounce correctly?

That is, wouldn't you usually store the job like this._job = Polymer.Debouncer.debounce(_job ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Updated with hopefully a more clear example.

*
* Note: In testing it is often convenient to avoid asynchrony. To accomplish
* this with a debouncer, you can use `Polymer.enqueueDebouncer` and
* `Polymer.flush`. For example, extend the above example by adding
* `Polymer.enqueueDebouncer(job)`. Then in a test, call `Polymer.flush` to
* ensure the debouncer has completed.
*
* @param {Polymer.Debouncer?} debouncer Debouncer object.
* @param {!AsyncModule} asyncModule Object with Async interface
Expand Down