-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from declandewet/watcher-logic
circumvent need to call refresh() after async actions
- Loading branch information
Showing
5 changed files
with
53 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Performs a batched update. Uses requestAnimationFrame to prevent | ||
* calling a function too many times in quick succession. | ||
* You need to pass it an ID (which can initially be `null`), | ||
* but be sure to overwrite that ID with the return value of batchUpdate. | ||
* | ||
* @param {(null|Number)} id - the ID of this update | ||
* @param {Function} callback - the update to perform | ||
* @return {Number} id - a new ID | ||
*/ | ||
export default function batchUpdate (id, callback) { | ||
window.cancelAnimationFrame(id) | ||
return window.requestAnimationFrame(() => { | ||
id = null | ||
callback() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters