Skip to content

Commit

Permalink
Use ES2015 destructuring assignment to swap vars
Browse files Browse the repository at this point in the history
This commit uses ES2015 destructuring assignment to swap two variables
instead of using a tmp var. Flow has an open issue (facebook/flow#183)
with this feature, though, so // $FlowFixMe is used to temporarily
suppress the error.
  • Loading branch information
An Phan committed Jan 7, 2017
1 parent 17be581 commit af1632d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/core/observer/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,11 @@ export default class Watcher {
dep.removeSub(this)
}
}
let tmp = this.depIds
this.depIds = this.newDepIds
this.newDepIds = tmp
this.newDepIds.clear()
tmp = this.deps
this.deps = this.newDeps
this.newDeps = tmp
// $FlowFixMe
[this.depIds, this.newDepIds] = [this.newDepIds, this.depIds]
this.newDepIds.clear();
// $FlowFixMe
[this.deps, this.newDeps] = [this.newDeps, this.deps]
this.newDeps.length = 0
}

Expand Down

0 comments on commit af1632d

Please sign in to comment.