function Watcher(tree, mapping) {
    var _this;

    _this = _Emitter.call(this) || this; // Properties

    _this.tree = tree;
    _this.mapping = null;
    _this.state = {
      killed: false
    }; // Initializing

    _this.refresh(mapping); // Listening


    _this.handler = function (e) {
      if (_this.state.killed) return;

      var watchedPaths = _this.getWatchedPaths();

      if ((0, _helpers.solveUpdate)(e.data.paths, watchedPaths)) return _this.emit('update');
    };

    _this.tree.on('update', _this.handler);

    return _this;
  }
Watcher class.

@constructor
@param {Baobab} tree     - The watched tree.
@param {object} mapping  - A mapping of the paths to watch in the tree.