Sometimes the list of all computed values in your program is not known apriori.
In that case you have to create an array that will store computeds for each value.
There is an idea to introduce parametric computeds. You will be able to "curry" some parametrs that will be passed to your computed.
The calculated value will be cached and associated with the passed parameters
var c = itDepends.value(1);
var d = itDepends.computed(function(a, b) {
return Math.sqrt(b*b - 4*a*c());
});
console.log(d(2, 1)); // calculation
console.log(d(2, 1)); // cached value
console.log(d(10, 5)); // calculation
console.log(d(10, 5)); // cached value
console.log(d(2, 1)); // cached value
c(2);
console.log(d(10, 5)); // calculation
console.log(d(2, 1)); // calculation
console.log(d(2, 1)); // cached value
Concerns
Parametric syntax conflicts with writable computed syntax. Idea is to make a breaking changeand introduce explicit write method
There should be also some kind of curry method, so you will be able to get the child computed with fixed set of parameters
Sometimes the list of all computed values in your program is not known apriori. In that case you have to create an array that will store computeds for each value. There is an idea to introduce parametric computeds. You will be able to "curry" some parametrs that will be passed to your computed. The calculated value will be cached and associated with the passed parameters
Concerns Parametric syntax conflicts with writable computed syntax. Idea is to make a breaking changeand introduce explicit write method There should be also some kind of curry method, so you will be able to get the child computed with fixed set of parameters