feat(web): mqtt for stats

This commit is contained in:
Paul Armstrong
2021-02-15 20:10:20 -08:00
committed by Blake Blackshear
parent 20c65b9a31
commit e399790442
6 changed files with 260 additions and 72 deletions

View File

@@ -1,5 +1,6 @@
import { baseUrl } from './baseUrl';
import { h, createContext } from 'preact';
import { MqttProvider } from './mqtt';
import produce from 'immer';
import { useContext, useEffect, useReducer } from 'preact/hooks';
@@ -41,7 +42,11 @@ function reducer(state, { type, payload, meta }) {
export const ApiProvider = ({ children }) => {
const [state, dispatch] = useReducer(reducer, initialState);
return <Api.Provider value={{ state, dispatch }}>{children}</Api.Provider>;
return (
<Api.Provider value={{ state, dispatch }}>
<MqttProvider>{children}</MqttProvider>
</Api.Provider>
);
};
function shouldFetch(state, url, fetchId = null) {