Sha256: 65c36b4aec14def61f0b7700992cf50972235c3cffacc22af96eade20ca7510a
Contents?: true
Size: 979 Bytes
Versions: 3
Compression:
Stored size: 979 Bytes
Contents
var _ = require('../util') /** * A dep is an observable that can have multiple * directives subscribing to it. * * @constructor */ function Dep () { this.subs = [] } // the current target watcher being evaluated. // this is globally unique because there could be only one // watcher being evaluated at any time. Dep.target = null var p = Dep.prototype /** * Add a directive subscriber. * * @param {Directive} sub */ p.addSub = function (sub) { this.subs.push(sub) } /** * Remove a directive subscriber. * * @param {Directive} sub */ p.removeSub = function (sub) { this.subs.$remove(sub) } /** * Add self as a dependency to the target watcher. */ p.depend = function () { Dep.target.addDep(this) } /** * Notify all subscribers of a new value. */ p.notify = function () { // stablize the subscriber list first var subs = _.toArray(this.subs) for (var i = 0, l = subs.length; i < l; i++) { subs[i].update() } } module.exports = Dep
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
plate-lang-0.1.2 | skeleton/vendor/vue/src/observer/dep.js |
plate-lang-0.1.1 | skeleton/vendor/vue/src/observer/dep.js |
plate-lang-0.1.0 | skeleton/vendor/vue/src/observer/dep.js |