changing dependentObservable() function, to enable chained writes

31 views
Skip to first unread message

shoky

unread,
Apr 23, 2012, 7:06:38 PM4/23/12
to knock...@googlegroups.com
Hi
I've found out (thanks to this forum) that for computed observables, it's not possible to chain writes like this:
viewModel.someComputed(20).otherComputed(100).someObservable('hi')

and this bummed me because I have many observables which I now want to extend - so they will become computed,
and so I have to remove all the chained calls.

So I've made this small change in the dependantObservable() function (just added: return this;)

    function dependentObservable() {
        if (arguments.length > 0) {
            set.apply(dependentObservable, arguments);
            return this;
        } else {
            return get();             
        }
    }

And now I can chain writes!

My question is: what's the downside of doing this?
I assume there is one, because this wasn't implemented :P

Thanks,
Uri G
Reply all
Reply to author
Forward
0 new messages