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

vue3-rsocket

v0.3.1

Published

Vue3 library for rsocket-js https://github.com/rsocket/rsocket-js

Downloads

5

Readme

vue3-rsocket

What is RSocket?

Check out the official docs: RSocket Docs

Most interesting:

Network communication is asynchronous. The RSocket protocol embraces this and models all communication as multiplexed streams of messages over a single network connection, and never synchronously blocks while waiting for a response

This library for vue3 enables to easily connect to an RSocket server and react on incoming messages.

Currently, only requestStream is supported. But this could be easily extended. Feel free to open a PR.

Motivation

The goal of this library is to wrap the functionality of rsocket-js in an easy-to-use plugin for Vue 3.

An example implementation of RSocket using a SpringCloud Gateway can be found here.

Example

:building_construction: Add an example project using this library

:floppy_disk: Installation

yarn add vue3-rsocket

or

npm install --save vue3-rsocket

:gear: Setup

For all possible configuration values have look at src/classes/RSocketConfig.ts.

Vue 3

:building_construction: Add setup instructions for vue3 project

Quasar

JWT

import { boot } from "quasar/wrappers";
import { Vue3RSocket, BearerAuth, RSocketConfig } from "vue3-rsocket";

export default boot(async ({ app }) => {

  const rSocketConfig = new RSocketConfig({
    url: `ws://localhost:8070/server/rsocket`,
    authFn: async () => new BearerAuth(token).asAuthentication(),
    debug: true
  });

  await app.use(Vue3RSocket, rSocketConfig);
});

Basic auth

import { boot } from "quasar/wrappers";
import { Vue3RSocket, UserAuth, RSocketConfig } from "vue3-rsocket";

export default boot(async ({ app }) => {

  const rSocketConfig = new RSocketConfig({
    url: `ws://localhost:8070/server/rsocket`,
    authFn: async () => new UserAuth("username", "password").asAuthentication(),
    debug: true
  })

  await app.use(Vue3RSocket, rSocketConfig);
});

:envelope: Usage

<script>
import { onBeforeUnmount, inject } from "vue";
import { RequestStreamInformation } from "vue3-rsocket";

export default {
 setup() {
   const rs = inject("vue3-rsocket");

   rs.requestStream("route", (data) => console.log(data));

   rs.requestStream(
     "routeWithMetadata",
     (data) => console.log(data),
     new RequestStreamInformation({
       data: "Hey",
       metaData: { requester: "Fred Flintstone" },
     })
   );

   // Unsubschribe before component is destroyed.
   onBeforeUnmount(() => {
     rs.cancelRequestStream("route");
     rs.cancelRequestStream("routeWithMetadata");
   });
 },
};
</script>

Development

We currently use Yarn v1 for this project (v1 to not break dependency updated provided by dependabot).

To build the project hit:

yarn && yarn build

all generated filed will then be located in dist/.


To build when something in src/ changed, use:

yarn dev

and to test it in your desired project hit yarn link {{absolute-path-to}}/vue3-rsocket.

Next up

  • [x] Add dependabot
  • [ ] Add Vue setup example
  • [ ] Add full example project with front and backend
  • [ ] Expose more configuration parameters
  • [ ] Implement local subscriptions
  • [ ] Implement more than the request-stream interaction model

Disclaimer

We are pretty new to RSocket and library publishing, so this code or the bundling process might not be optimized, suggestions are welcome. Also, we are pretty new to TypeScript, so this code might not be in the best shape possible.

:handshake: Contributing

Every contribution is highly appreciated!