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

v-socket-io-plugins

v1.0.8

Published

vue项目种使用socket.io-client的封装

Downloads

1

Readme

vue 全局插件对 socket.io-client 进行的封装

  • 支持创建多消息通道与管理
import socketIo, {
  createSocket,
  getSocket,
  closeSocket,
} from 'v-socket-io-plugins';
Vue.use(socketIo);
//创建socket实例【socketKey标记字段必传,更多参数可以查看socket官网】
createSocket(
  'http://......',
  {
    socketKey: 'testSocket',
    // ......
  },
  function () {
    console.log('testSocket链接成功');
  }
);
// 附属:如果多页面或者多组件需要监听链接成功事件时
// 注意:需要在页面或者组件都加载完成后链接成功事件才能接收。

//获取socket实例【得到实例后可做更多的操作,更多操作可以查看socket官网】
getSocket('testSocket');

//主动关闭socket实例
closeSocket('testSocket');

//推送消息【更多消息类型以及参数可以查看socket官网】
getSocket('testSocket').send('消息内容');

// 添加自定义事件
getSocket('testSocket').on('push_event', function (msg) {
  console.log(msg);
});

//更多使用方法查看官网......
export default {
  /***
   * socket可以是对象,也可以是数组,如果同时要连接多个连接时就用数组包含多个对象的形式
   */
  socket: {
    /**
     * 支持组件或者页面配置形式创建socket,配置形式只支持挂载是创建一个通道,并且在注销是会关闭通道
     */
    //链接地址
    connection: 'http://......',
    //参数
    options: {
      socketKey: 'testSocket',
      // ......
    },
    // 任何页面或组件监听消息数据接收
    message(msg) {
      console.log(msg);
    },
    // 任何页面或组件监听通道链接成功
    connect() {
      console.log('链接成功回调');
    },
    // 任何页面或组件监听通道关闭
    disconnect() {
      console.log('链接关闭回调');
    },
    // 任何页面或组件监听自定义事件
    events: {
      define_events(msg) {
        console.log(msg);
      },
    },
  },
};

原作者

  • levy

创建时间

  • 2020-12-22