-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
27 lines (22 loc) · 1017 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import './style.css';
import { dispatch, subscribe } from './src/store/store.js';
import TemperatureCard from './src/components/TemperatureCard.js';
import TemperatureTable from './src/components/TemperatureTable.js';
import Chart from './src/components/Chart/Chart.js';
import { addReadingAction } from './src/store/actions.js';
import { getCurrentTemperature } from './src/services/temperature.service.js';
import { getCurrentLocation } from './src/services/location.service.js';
import { poll } from './src/services/utils.js';
const location = (await getCurrentLocation()) || 'London';
const setupComponent = (component) => {
if (typeof component.mount === 'function') {
// attach the static part of the component's markup to the DOM
component.mount();
}
subscribe(component);
};
const addReading = (reading) => dispatch(addReadingAction(reading));
setupComponent(TemperatureCard);
setupComponent(TemperatureTable);
setupComponent(Chart);
void poll(location, getCurrentTemperature, addReading);