DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
    • can-construct-super
    • can-define-stream
      • behaviors
        • stream
      • DefineMap.prototype
        • stream
      • DefineList.prototype
        • stream
    • can-fixture
    • can-fixture-socket
    • can-jquery
    • can-stache-converters
    • can-stream
    • can-vdom
    • can-view-import
    • can-zone
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-define-stream
  • / On this page
    • can-define-stream

      module

      Define property values using streams. can-stream is used internally to provide the stream functionality.

      • source

      undefined

      The can-define-stream module doesn't export anything. Instead it changes can-define to support the stream behavior and can-define/map/map and can-define/list/list to have a stream method that's a shorthand for toStream.

      require("can-define-stream");
      var DefineMap = require("can-define/map/map");
      
      var Person = DefineMap.extend({
          first: "string",
          last: "string"
          get fullName() {
              return this.first + " " + this.last;
          },
          fullNameChangeCount: {
              stream: function(setStream) {
                  return this.stream(".fullName").scan(function(last){
                      return last + 1;
                  },0)
              }
          }
      });
      
      var me = new Person({first: "Justin", last: "Meyer"});
      
      me.on("fullNameChangeCount", function(ev, newVal){
          console.log(newVal);
      });
      
      me.fullNameChangeCount //-> 0
      
      me.first = "Obaid"
      //-> console.logs 1
      
      me.last = "Ahmed"
      //-> console.logs 2
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.