npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@efox/svc

v1.24.2

Published

svc工具库

Downloads

22

Readme

@efox/svc

与中台服务端通信的工具库

示例步骤

安装

yarn add @efox/svc

代码执行顺序(具体参数查看api文档)

import svc from '@efox/svc'

// 初始化
await svc.init(options)

// 订阅房间
const unsubscribe = await svc.subscribeBcGroup({
    groupId,
    groupType
})

// 通信并获取同步返回数据
const res = await svc.channel({
    protoPkgName: '',
    protoFileName: '',
    messageReq: '',
    messageResp: '',
    svcName: '',
    fnName: '',
    data: {}
})

// 添加接收单播和广播的某事件处理方法
svc.useBroadcastMiddlePlugins({
    protoFileName: '',
    messageResp: '',
    svcName: '',
    fnName: '',
    callback: (data: any) => {
      // 监听后的执行方法
    }
})

// 取消订阅
unsubscribe()

api文档

初始化实例(init)

import svc from '@efox/svc'
await svc.init(options)

请求参数:Object

| Name | Type | Description | | --------- | ----------------------- | --------------------------------------------------- | | uid | string | 用户uid(没传原始hummer时,必须传) |
| otp | string | 用户token(没传原始hummer时,必须传) | | appid | string | 应用appid(没传原始hummer时,必须传) | | region | string | 用户区域(没传原始hummer时,必须传) | | hummer? | Hummer | 特定hummer(如果传的话,就不需要传上面参数了) |

响应数据:void

订阅和取消房间信息(subscribeBcGroup)

// 订阅
const unsubscribe = await svc.subscribeBcGroup({
    groupId,
    groupType
})

// 取消
unsubscribe()

请求参数:Object

| Name | Type | Description | | --------- | ----------------------- | --------------------------------------------------- | | groupId | string | 房间id | | groupType | string | 频道 |

响应数据:Function

执行渠道方法(channel)

const res = await svc.channel({
    protoPkgName: '',
    protoFileName: '',
    messageReq: '',
    messageResp: '',
    svcName: '',
    fnName: '',
    data: {}
})

请求参数:Object

| Name | Type | Description | | --------- | ----------------------- | --------------------------------------------------- | | protoPkgName? | string | proto的包名 | | protoFileName | string | proto文件名或文件名的相对路径如https://***/.proto | | messageReq | string | 解析请求数据格式 | | messageResp | string | 解析返回数据格式 | | svcName | string | svc渠道名字 | | fnName | string | 方法名字 | | data | object | 传递数据 |

响应数据:Promise

| Name | Type | Description | | --------------------- | ----------------- | --------- | | rescode | number | 0:表示成功 |

接收单播和广播时处理中间件(useBroadcastMiddlePlugins)

添加接收单播和广播时,对某事件的处理方法

svc.useBroadcastMiddlePlugins({
    protoFileName: '',
    messageResp: '',
    svcName: '',
    fnName: '',
    callback: (data: any) => {
      
    }
})

请求参数:Object

| Name | Type | Description | | --------- | ----------------------- | --------------------------------------------------- | | protoPkgName? | string | proto的包名 | | protoFileName | string | proto文件名或文件名的相对路径如https://***/.proto | | messageResp | string | 解析返回数据 | | svcName | string | svc渠道名字 | | fnName | string | 方法名字 | | callback | function | 处理函数 |