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

@sqwad/direct-flow

v1.1.0

Published

Direct Flow Client

Downloads

3

Readme

Sqwad DirectFlow Client Javascript / Typescript library

Instant bidirectional interactions made easy !

Note: we use socket.io library for client layer with auto-reconnect and WebSocket / Long polling usage.

The library is coded on typescript so all types are defined, except for custom ones.

CDN Use

<script src="https://cdn.jsdelivr.net/npm/@sqwad/direct-flow" crossorigin="anonymous"></script>
<script>
  const d = new DirectFlow('your-uuid', 'client-key')

  d.broadcast('Hello world')

  d.onMessage((message) => {
    console.log(message)
  })
</script>

Installation

yarn add @sqwad/direct-flow

or

npm install @sqwad/direct-flow

Javascript Usage


<script type="module">
    import {DirectFlow} from '@sqwad/direct-flow'

    const d = new DirectFlow('your-uuid', 'client-key')

    d.broadcast('Hello world')

    d.onMessage((message) => {
        console.log(message)
    })
</script>

Event driven usage


<script type="module">
    import {DirectFlow} from '@sqwad/direct-flow'

    const d = new DirectFlow('your-uuid', 'client-key')

    d.broadcast('Hello world')

    // Instantiate all event dispatchers
    d.onMessage()

    addEventListener(DirectFlowEventType.GLOBAL, (message) => console.log(message))
</script>

Methods

  • connect: connect to server (not needed, connected in constructor)
  • release: disconnect from server
  • broadcast: send message to anyone except us (can be string or object)
  • send: broadcast alias
  • sendTo: send to specific client
  • sendToChannel: send to channel on server (can be string or object)
  • rawSend: send any data to server, but need to be an object
  • subscribe: listen to one or more specific channel (string or object)
  • unsubscribe: stop listening for one or more specific channel (string or object)
  • onMessage: action to do when receiving message, parameter is optional and instantiate event dispatchers, you should call once only.