Sha256: 4cf2258335199ef3940e2822b996bb3c3579c094d4dfd9b08e8db3d357a3ba8b

Contents?: true

Size: 717 Bytes

Versions: 5

Compression:

Stored size: 717 Bytes

Contents

var uid = 0

/**
 * A dep is an observable that can have multiple
 * directives subscribing to it.
 *
 * @constructor
 */

function Dep () {
  this.id = ++uid
  this.subs = []
}

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) {
  if (this.subs.length) {
    var i = this.subs.indexOf(sub)
    if (i > -1) this.subs.splice(i, 1)
  }
}

/**
 * Notify all subscribers of a new value.
 */

p.notify = function () {
  for (var i = 0, l = this.subs.length; i < l; i++) {
    this.subs[i].update()
  }
}

module.exports = Dep

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fluentd-ui-0.3.13 vendor/assets/javascripts/bower/vue/src/observer/dep.js
fluentd-ui-0.3.12 vendor/assets/javascripts/bower/vue/src/observer/dep.js
fluentd-ui-0.3.11 vendor/assets/javascripts/bower/vue/src/observer/dep.js
fluentd-ui-0.3.10 vendor/assets/javascripts/bower/vue/src/observer/dep.js
fluentd-ui-0.3.9 vendor/assets/javascripts/bower/vue/src/observer/dep.js