0.0.1 • Published 4 years ago
worker-ws-client v0.0.1
worker-ws-client
🚄 使用教程
安装
npm i install worker-ws-client --save-dev or yarn add worker-ws-client --save-dev使用
import WorkerWsClient from "worker-ws-client"
class WsClient extends WorkerWsClient {
constructor(){
super()
this._worker.addEventListener('message', e => {
})
}
}📖 文档
WsWorkerClient
new WsWorkerClient()
构建WsWorkerClient实例
wsWorkerClient.postMessage(message, transfer)
通过worker 发送消息
| Param | Type | Description |
|---|---|---|
| message | Object | {type:string,args:Array} |
| transfer | * |
wsWorkerClient.send(params, asyncCallback)
| Param | Type | Description |
|---|---|---|
| params | Object | 消息类型加参数数据 |
| asyncCallback | Fucntion | 存储回调方法 |
wsWorkerClient.init(websocketUrl)
初始化websocket
| Param | Type | Description |
|---|---|---|
| websocketUrl | String | websocket地址 |
0.0.1
4 years ago