client metadata caching

This commit is contained in:
Jan Prochazka
2020-04-12 20:47:24 +02:00
parent cd645afd00
commit e9c03345c3
8 changed files with 88 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
import io from 'socket.io-client';
import React from 'react';
import resolveApi from './resolveApi';
import { cacheClean } from './cache';
const SocketContext = React.createContext(null);
@@ -10,6 +11,7 @@ export function SocketProvider({ children }) {
// const newSocket = io('http://localhost:3000', { transports: ['websocket'] });
const newSocket = io(resolveApi());
setSocket(newSocket);
newSocket.on('clean-cache', (reloadTrigger) => cacheClean(reloadTrigger));
}, []);
return <SocketContext.Provider value={socket}>{children}</SocketContext.Provider>;
}