Fix step-wise formulas causing issues with reactivity

This commit is contained in:
thepaperpilot 2023-05-12 01:39:06 -05:00
parent 213bdd6005
commit 8284baa1a0

View file

@ -229,15 +229,16 @@ export abstract class InternalFormula<T extends [FormulaSource] | FormulaSource[
start: Computable<DecimalSource>,
formulaModifier: (value: InvertibleIntegralFormula) => GenericFormula
) {
const lhsRef = ref<DecimalSource>(0);
const formula = formulaModifier(Formula.variable(lhsRef));
const formula = formulaModifier(Formula.variable(0));
const processedStart = convertComputable(start);
function evalStep(lhs: DecimalSource) {
if (Decimal.lt(lhs, unref(processedStart))) {
return lhs;
}
lhsRef.value = Decimal.sub(lhs, unref(processedStart));
return Decimal.add(formula.evaluate(), unref(processedStart));
return Decimal.add(
formula.evaluate(Decimal.sub(lhs, unref(processedStart))),
unref(processedStart)
);
}
function invertStep(value: DecimalSource, lhs: FormulaSource) {
if (hasVariable(lhs) && formula.isInvertible()) {