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
  • /
  • stream
  • / On this page
    • stream

      typedef

      Define a property value from a stream of values.

      • source

      stream( setterStream )

      The stream behavior is an available property definition on the PropDefinition of all can-define types.

      It is useful for deriving values that get can not, for example deriving values based around the change in another value intead of the values themselves.

      var Person = DefineMap.extend({
        name: "string",
        lastValidName: {
          stream: function(){
            return this.stream(".name").filter(function(name){
              return name.indexOf(" ") >= 0;
            })
          }
        }
      });
      
      var me = new Person({name: "James"});
      
      me.on("lastValidName", function(lastValid) {
        console.log(lastValid)
      });
      
      me.name = "JamesAtherton";
      
      me.name = "James Atherton";
      //-> console.logs "James Atherton";
      
      me.name = "JustinMeyer";
      
      me.name = "Justin Meyer";
      //-> console.logs "Justin Meyer";
      

      The property must be bound before a value can be read.

      Parameters

      1. setterStream {Stream}:

        The stream of values set on this property like obj.prop = value.

      Returns

      {Stream}:

      A stream whose last value will be used as the property value.

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