Fix step-wise formulas causing issues with reactivity
This commit is contained in:
parent
213bdd6005
commit
8284baa1a0
1 changed files with 5 additions and 4 deletions
|
@ -229,15 +229,16 @@ export abstract class InternalFormula<T extends [FormulaSource] | FormulaSource[
|
||||||
start: Computable<DecimalSource>,
|
start: Computable<DecimalSource>,
|
||||||
formulaModifier: (value: InvertibleIntegralFormula) => GenericFormula
|
formulaModifier: (value: InvertibleIntegralFormula) => GenericFormula
|
||||||
) {
|
) {
|
||||||
const lhsRef = ref<DecimalSource>(0);
|
const formula = formulaModifier(Formula.variable(0));
|
||||||
const formula = formulaModifier(Formula.variable(lhsRef));
|
|
||||||
const processedStart = convertComputable(start);
|
const processedStart = convertComputable(start);
|
||||||
function evalStep(lhs: DecimalSource) {
|
function evalStep(lhs: DecimalSource) {
|
||||||
if (Decimal.lt(lhs, unref(processedStart))) {
|
if (Decimal.lt(lhs, unref(processedStart))) {
|
||||||
return lhs;
|
return lhs;
|
||||||
}
|
}
|
||||||
lhsRef.value = Decimal.sub(lhs, unref(processedStart));
|
return Decimal.add(
|
||||||
return Decimal.add(formula.evaluate(), unref(processedStart));
|
formula.evaluate(Decimal.sub(lhs, unref(processedStart))),
|
||||||
|
unref(processedStart)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
function invertStep(value: DecimalSource, lhs: FormulaSource) {
|
function invertStep(value: DecimalSource, lhs: FormulaSource) {
|
||||||
if (hasVariable(lhs) && formula.isInvertible()) {
|
if (hasVariable(lhs) && formula.isInvertible()) {
|
||||||
|
|
Loading…
Reference in a new issue