readOptions
- typedef
can.view.Scope.readOptions
{Object}
An options object used to configure read.
Object
Properties
-
isArgument
{Boolean}
OptionalIf 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
-
foundObservable
{function(observe, readIndex)}
OptionalfoundObservable
is called when the first observable is found along the path along the read path. It's called with thereadIndex
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 }} )
-
observe
{can.compute(getterSetter, context) | can.Map}
-
readIndex
{Number}
-
-
earlyExit
{function(observe, readIndex)}
OptionalIs called if a value is not found.
-
observe
{can.compute(getterSetter, context) | can.Map}
-
readIndex
{Number}
-
-
args
{Array}
An array of arguments to pass to observable prototype methods.
-
returnObserveMethods
{Boolean}
OptionalIf 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
-
proxyMethods
=true
{Boolean}
OptionalSet to false to return just the function, preventing returning a function that always calls the original function with this as the parent.