Move WorkerPoolContext into WorkerPool.ts

This commit is contained in:
Tyler Hallada 2022-03-04 23:53:36 -05:00
parent eebae85a65
commit 5dd061627a
3 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import React, { useContext } from "react"; import React, { useContext } from "react";
import { WorkerPoolContext } from "../pages/index"; import { WorkerPoolContext } from "../lib/WorkerPool";
import { useAppDispatch } from "../lib/hooks"; import { useAppDispatch } from "../lib/hooks";
import { clearPlugins, setPending } from "../slices/plugins"; import { clearPlugins, setPending } from "../slices/plugins";
import styles from "../styles/DataDirPicker.module.css"; import styles from "../styles/DataDirPicker.module.css";

View File

@ -1,3 +1,5 @@
import { createContext } from "react";
import { import {
addPluginInOrder, addPluginInOrder,
decrementPending, decrementPending,
@ -78,4 +80,6 @@ export class WorkerPool {
} }
this.availableWorkers = []; this.availableWorkers = [];
} }
} }
export const WorkerPoolContext = createContext<WorkerPool | null>(null);

View File

@ -1,4 +1,4 @@
import { createContext, useEffect, useCallback, useState } from "react"; import { useEffect, useCallback, useState } from "react";
import type { NextPage } from "next"; import type { NextPage } from "next";
import Head from "next/head"; import Head from "next/head";
import "mapbox-gl/dist/mapbox-gl.css"; import "mapbox-gl/dist/mapbox-gl.css";
@ -6,9 +6,7 @@ import "mapbox-gl/dist/mapbox-gl.css";
import Map from "../components/Map"; import Map from "../components/Map";
import { useAppDispatch } from "../lib/hooks"; import { useAppDispatch } from "../lib/hooks";
import { setPluginsTxtAndApplyLoadOrder } from "../slices/pluginsTxt"; import { setPluginsTxtAndApplyLoadOrder } from "../slices/pluginsTxt";
import { WorkerPool } from "../lib/WorkerPool"; import { WorkerPool, WorkerPoolContext } from "../lib/WorkerPool";
export const WorkerPoolContext = createContext<WorkerPool | null>(null);
const Home: NextPage = () => { const Home: NextPage = () => {
const [workerPool, setWorkerPool] = useState<WorkerPool | null>(null); const [workerPool, setWorkerPool] = useState<WorkerPool | null>(null);