https://github.com/technote-space/worker-controller
Worker Controller
https://github.com/technote-space/worker-controller
Last synced: 8 months ago
JSON representation
Worker Controller
- Host: GitHub
- URL: https://github.com/technote-space/worker-controller
- Owner: technote-space
- License: mit
- Created: 2020-05-10T06:14:18.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-18T22:10:05.000Z (over 2 years ago)
- Last Synced: 2025-04-04T14:54:54.253Z (9 months ago)
- Language: TypeScript
- Homepage:
- Size: 1.04 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Worker Controller
[](https://badge.fury.io/js/%40technote-space%2Fworker-controller)
[](https://github.com/technote-space/worker-controller/actions)
[](https://www.codefactor.io/repository/github/technote-space/worker-controller)
[](https://github.com/technote-space/worker-controller/blob/main/LICENSE)
Worker Controller
## Table of Contents
Details
- [Setup](#setup)
- [Author](#author)
## Setup
```shell script
yarn add @technote-space/worker-controller
```
`Pgocess.ts`
```typescript
import {ProcessBase} from '@technote-space/worker-controller';
import {UpdateResult} from './types';
global['Process'] = class Process extends ProcessBase {
//...
};
```
`webpack.js`
```js
module.exports = {
//...
entry: {
index: path.join(__dirname, 'src/index.jsx'),
// create worker-controller.worker.js
'worker-controller.worker': '@technote-space/worker-controller/dist/Worker/worker-controller.worker',
// create process.js
process: path.join(__dirname, 'src/Process'),
},
output: {
//...
filename: '[name].js',
},
//...
};
```
`Run.jsx`
```typescript jsx
import React, {useEffect, useMemo, useState} from 'react';
import {Button} from '@material-ui/core';
import {Controller} from '@technote-space/worker-controller';
export default function NavContentEx() {
const [worker, setWorker] = useState(null);
useEffect(() => {
const worker = new Controller(result => {
//...
});
setWorker(worker);
worker.reset();
}, []);
return useMemo(() => !worker ? null : <>
worker.reset()}>Reset
worker.start()}>Start
worker.stop()}>Stop
>, [worker])
}
```
## Author
[GitHub (Technote)](https://github.com/technote-space)
[Blog](https://technote.space)