Skip to content

Commit

Permalink
use Promise to update head (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkzawa authored and rauchg committed Dec 30, 2016
1 parent 1fbf324 commit f7ee503
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client/head-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const DOMAttributeNames = {

export default class HeadManager {
constructor () {
this.requestId = null
this.updatePromise = null
}

updateHead (head) {
// perform batch update
window.cancelAnimationFrame(this.requestId)
this.requestId = window.requestAnimationFrame(() => {
this.requestId = null
const promise = this.updatePromise = Promise.resolve().then(() => {
if (promise !== this.updatePromise) return

this.updatePromise = null
this.doUpdateHead(head)
})
}
Expand Down

0 comments on commit f7ee503

Please sign in to comment.