# worker-bus

> Dashboard data load by socket through web-worker

Latest version **1.0.5** (published 2022-08-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install worker-bus
pnpm add worker-bus
yarn add worker-bus
bun add worker-bus
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2022-08-31 |
| First published | 2022-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 472.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Alibob |
| Maintainers | alibob |
| Keywords | Dashboard, web worker, web socket |

## Links

- npm: https://www.npmjs.com/package/worker-bus
- npm.io page: https://npm.io/package/worker-bus

## Dependencies (1)

- [vue](https://npm.io/package/vue.md) ^2.6.11

## Recent versions

- 1.0.5 (latest) — 2022-08-31
- 1.0.4 — 2022-08-30
- 1.0.3 — 2022-08-15
- 1.0.2 — 2022-07-14
- 1.0.1 — 2022-07-14
- 1.0.0 — 2022-07-14

## README

## 使用说明 Usage

### 引入 Import
```
//main.js
import WorkerBus from "worker-bus";
Vue.use(WorkerBus);
```



### Vue中使用$wb
```
<!-- worker.js -->
$wb.one('./worker.js')
<!-- config Loop valid -->
$wb.configValid((loopID, data) => loopID == data.loopID)

<!-- 获取socket状态 -->
this.$wb.on('__socket__status', (payload) => {
    this.socket_status = payload.data.status
})

<!-- 获取socket回调队列 -->
this.$wb.on('__socket__queue', (payload) => {
    this.socket_queue = payload.data.queue
})  
<!-- 注册定时任务 -->
this.$wb.register([
        { loopID: 1, data: { payload: { from: 'localhost', target: 'demo:200ms', id: '10001' }, timeout: 60, loop: true } }
])
<!-- 监听数据返回 60ms 返回一次-->
this.$wb.on(1, msg => {
    console.log(msg.count)
})

```

### DEMO

```
//启动静态服务器 http://localhost:8080
npm run dev
```
```
// 启动websocket服务器 ws://localhost:3000/basic
npm run server:dev
```

---
_Source: https://npm.io/package/worker-bus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
