Skip to content

Latest commit

 

History

History
81 lines (52 loc) · 1.73 KB

README.md

File metadata and controls

81 lines (52 loc) · 1.73 KB

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地址