I'm trying to use can.compute seter with initial value.
Initial value is works correctly, but setter doesn't works.
I mean this construction "
Check yourself
http://jsbin.com/OjEhIsaG/watch?js,output
Initial value is works correctly, but setter doesn't works.
I mean this construction "
can.compute(initialValue, setterFn)
" behaves like this "can.compute(initialValue)
"Check yourself
http://jsbin.com/OjEhIsaG/watch?js,output
- can.Component.extend({
- tag: "my-tag",
- template: "<button>click</button> {{val}}",
- scope : {
- val : can.compute('default val', function(newVal) {
- alert('this function will never be called');
- return 'I am the real value';
- })
- },
- events : {
- 'button click' : function(el) {
- this.scope.val(Math.random());
- }
- }
- });
- var template = can.view.mustache("<my-tag></my-tag>");
- $("body").html(template());