LEDVisionのリアルタイム動作化

This commit is contained in:
harukin-DeskMini 2022-04-22 05:44:59 +09:00
parent 6b54d01030
commit db218609a8

View File

@ -113,8 +113,11 @@ export default function LED_vision(props){
};
const trainTimeAndNumber = stationDiagram != null ? getTime() : null;
useEffect(()=>{
fetch("https://train.jr-shikoku.co.jp/g?arg1=train&arg2=train", HeaderConfig).then(response => response.json()).then(d=>d.map(x=>({num:x.TrainNum,delay:x.delay}))).then(d=>{
setCurrentTrain(d)});
const getCurrentTrain = () =>fetch("https://train.jr-shikoku.co.jp/g?arg1=train&arg2=train", HeaderConfig).then(response => response.json()).then(d=>d.map(x=>({num:x.TrainNum,delay:x.delay}))).then(d=>setCurrentTrain(d));
getCurrentTrain();
const currentTrainInterval = setInterval(()=>getCurrentTrain(),15000)
return ()=>clearInterval(currentTrainInterval);
},[])
const filtering = d => currentTrain.map(m=>m.num).includes(d.train)