import React, {useEffect, useState} from 'react';
import { EVENT_NAMES } from "../../enums/enums"
import "./style.scss"

const RpmDigital = (props) => {
    const [rpm, setRpm] = useState(8000);

    useEffect(
        () => {
          window.electron.receive(EVENT_NAMES.TELEMETRY_RPM, (rpm) => {
            setRpm(rpm)
          })
          return () => {
          };
        },[]
      );
    return (
        <div className="rpm-digital"> 
            <div className="rpm-digital__rpm">
                <div>{rpm.value ? Math.round(rpm.value) : ""}</div>
                <div>rpm</div>
            </div>
            
        </div>
    );
}

export default RpmDigital;