canjs / can-stream-kefir

Stream values into and out of computes
https://canjs.com/doc/can-stream-kefir.html
MIT License
3 stars 2 forks source link

Set getValueDependencies symbol to stream/compute results #56

Closed m-mujica closed 6 years ago

m-mujica commented 6 years ago
var Person = DefineMap.extend({
  first: "string",
  last: "string",
  fullName: {
    get: function() {
      return this.first + " " + this.last;
    }
  },
  fullNameChangeCount: {
    stream: function() {
      return this.toStream(".fullName").scan(function(last) {
        return last + 1;
      }, 0);
    }
  }
});

canDefineStreamKefir(Person);

var me = new Person({ name: "John", last: "Doe" });
draw(
    document.querySelector("#container"),
    getGraph(me, "fullNameChangeCount")
);

Generates the following dependency graph:

screen shot 2017-12-27 at 3 13 35 pm

Note how from the the fullNameChangeCount it can see deps all the way to DefineMap.first and DefineMap.last.