Last active
November 9, 2017 21:50
-
-
Save superMDguy/9d69b36fef029539683b3fee16171992 to your computer and use it in GitHub Desktop.
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
// See https://github.com/vuejs/vue/blob/be9ac624c81bb698ed75628fe0cbeaba4a2fc991/src/core/observer/dep.js | |
// for full implementation | |
class Dep { | |
constructor() { | |
this.subs = new Set() | |
} | |
addSub(sub) { | |
this.subs.add(sub) | |
} | |
depend() { | |
if (Dep.target) { | |
Dep.target.addDep(this) | |
} | |
} | |
notify() { | |
this.subs.forEach(sub => sub.update()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment