2024-10-07 13:47:20 +08:00
|
|
|
import { useDispatch } from "react-redux";
|
|
|
|
|
import { useNavigate } from "react-router";
|
|
|
|
|
import { setNetworkService } from "./NetworkService";
|
2025-01-27 11:37:44 +08:00
|
|
|
import NetworkService, { networkService } from "./NetworkService";
|
2024-10-07 13:47:20 +08:00
|
|
|
import { store } from "../store";
|
|
|
|
|
|
|
|
|
|
const NetworkServiceProvider = ({ children }) => {
|
2024-10-17 12:05:06 +08:00
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
const navigate = useNavigate();
|
2025-01-27 11:37:44 +08:00
|
|
|
if (!networkService) {
|
2025-01-27 12:21:46 +08:00
|
|
|
setNetworkService(new NetworkService(store, dispatch, navigate));
|
2025-01-27 11:37:44 +08:00
|
|
|
}
|
2024-10-17 12:05:06 +08:00
|
|
|
return children;
|
2024-10-07 13:47:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default NetworkServiceProvider;
|