readOptions

  • typedef
can.view.Scope.readOptions

{Object}

 

An options object used to configure read.

Object

Properties

  1. isArgument {Boolean}Optional

    If true, and the last value is a function or compute, returns that function instead of calling it.

    MyMap = can.Map.extend({method: function(){}});
    res = Scope.read( new MyMap(), 
                      ["method"],
                      {isArgument: true, proxyMethods: false} );
    res === MyMap.prototype.method //-> true
    
  2. foundObservable {function(observe, readIndex)}Optional

    foundObservable is called when the first observable is found along the path along the read path. It's called with the readIndex where the observable was found.

    var data = {person : new can.Map({name: "Justin"})}
    Scope.read( data, 
                ["person.name"],
                {foundObservable: function(observe, readIndex){
                  observe === data.person //-> true
                  readIndex //-> 1
                }} )
    
  3. earlyExit {function(observe, readIndex)}Optional

    Is called if a value is not found.

  4. args {Array}

    An array of arguments to pass to observable prototype methods.

  5. returnObserveMethods {Boolean}Optional

    If true, returns methods found on an observable. Otherwise, it will call the function with args as arguments and return the value.

    var Dog = can.Map.extend({
      age: function(){
        return this.attr("years")*7
      }
    })
    
    var dog = new Dog({years: 3});
    
    Scope.read(dog,"age",{}) //-> 21
    
    Scope.read(dog,
               "age",
               {returnObserveMethods: true})() //-> 21
    
  6. proxyMethods=true {Boolean}Optional

    Set to false to return just the function, preventing returning a function that always calls the original function with this as the parent.