From 5f479c1fb652a987ab8bb33e261d790030cdff38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A7=D0=B8=D0=BA=D0=B0=D0=BB=D0=BA=D0=B8=D0=BD?= Date: Mon, 31 Aug 2020 18:09:47 +0300 Subject: [PATCH] remove async in store --- src/client/Elements/Input.jsx | 10 +++++----- src/client/hocs/withTitle.jsx | 2 +- src/client/stores/CalculationStore/CalculationStore.ts | 10 ++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/client/Elements/Input.jsx b/src/client/Elements/Input.jsx index d0a3a8b..022d60b 100644 --- a/src/client/Elements/Input.jsx +++ b/src/client/Elements/Input.jsx @@ -29,11 +29,11 @@ const Input = ({ // set Value to global store and run Effects useEffect(() => { if (sourceValueName && debouncedValue) { - calculationStore.setValue(sourceValueName, debouncedValue).then(() => { - if (Effects && Effects.length > 0) { - runEffects(Effects, calculationStore); - } - }); + calculationStore.setValue(sourceValueName, debouncedValue); + } + + if (Effects && Effects.length > 0) { + runEffects(Effects, calculationStore); } }, [debouncedValue]); diff --git a/src/client/hocs/withTitle.jsx b/src/client/hocs/withTitle.jsx index 75f0722..0e5ee33 100644 --- a/src/client/hocs/withTitle.jsx +++ b/src/client/hocs/withTitle.jsx @@ -2,7 +2,7 @@ import React from "react"; import { Flex } from "client/UIKit/grid"; const withTitle = (title) => (Component) => (props) => ( - +
{title}
diff --git a/src/client/stores/CalculationStore/CalculationStore.ts b/src/client/stores/CalculationStore/CalculationStore.ts index a073550..6304330 100644 --- a/src/client/stores/CalculationStore/CalculationStore.ts +++ b/src/client/stores/CalculationStore/CalculationStore.ts @@ -10,12 +10,10 @@ class CalculationStore { getValue = (sourceValueName: SourceValueNames) => this.values[sourceValueName]; - setValue = action( - async (sourceValueName: SourceValueNames, newValue: any) => { - this.values[sourceValueName] = newValue; - // TODO: Run effect here - } - ); + setValue = action((sourceValueName: SourceValueNames, newValue: any) => { + this.values[sourceValueName] = newValue; + // TODO: Run effect here + }); getStatus = (elementName: string) => this.statuses[elementName]; setStatus = action((elementName: string, status: Status) => {