Skip to content

dep

js
class Dep{
    constructor() {
        this.subs = []
    }

    addSub(watcher){
        if(!watcher || !watcher.update) return
        this.subs.push(watcher)
    }

    notify(){
        this.subs.forEach(watcher => {
            watcher.update()
        })
    }
}
class Dep{
    constructor() {
        this.subs = []
    }

    addSub(watcher){
        if(!watcher || !watcher.update) return
        this.subs.push(watcher)
    }

    notify(){
        this.subs.forEach(watcher => {
            watcher.update()
        })
    }
}