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

@vmw/transport

v1.3.6

Published

Channel / stream based event bus & model store that extends to brokers via WebSockets & STOMP.

Downloads

23

Readme

Transport - TypeScript

Transport Post-merge pipeline codecov

Overview

What is Transport?

Transport is a lightweight, framework-agnostic event bus that simplifies state management in modern distributed web applications. This repository is the TypeScript implementation of the Transport event bus which provides a reactive publish-subscribe infrastructure along with built-in support for WebSocket over the STOMP to facilitate decoupling, modularization and universal design.

A distributed event bus

Transport can be distributed across applications and connected up to RabbitMQ, Kafka or NATS. It is also an API transport infrastructure & state store which enables actors using Transport to utilize similar API interfaces across different language implementations.

An internal freeway system, for applications.

Transport is part of VMware's UI architecture strategy. It decouples presentation logic, from business logic via an asynchronous event bus. This bus is built on top of ReactiveX that results in a super fast, super scalable mechanism for actors to communicate and decouple logic. Transport can be extended from communication within UI components (for managing Single Page Application states), to UI-to-backend or even backend-to-backend communication.

View Transport TypeScript Documentation

Transport Docs Repo

Quick Start

npm install @vmw/transport --save

Adding Transport to your web application

Option 1: ES6 module import (recommended)

This is the recommended way to import Transport as it allows build management tool such as Webpack to treeshake unused exports of the library shaving off some bits in size.

To import and initialize Transport, simply call BusUtil.bootBus() as follows:

import { BusUtil } from '@vmw/transport/util/bus.util';

// boot the event bus!
BusUtil.bootBus();

// once booted you can access the event bus instance from BusUtil.getInstance()
console.log(BusUtil.getInstance());

// you can destroy the event bus like this.
BusUtil.destroy();

// then boot the bus again with options to customize it. for example you can
// initialize the bus with the log level set to warning, the boot message
// enabled (second argument), and the dark console theme applied (third argument).
BusUtil.bootBusWithOptions(LogLevel.Warn, false, true);

Option 2: Using UMD module in Angular

Angular provides angular.json (for Angular 7+) and angular-cli.json (for Angular 4-5).

In this file, there is a section defined as scripts. This section is where you provide third party scripts to be booted and loaded by your Angular application.

You will need to add the Transport UMD file to this section. It's already been saved in your node_modules folder. Just provide an entry like the one below.

Configuring angular.json

...
"scripts": [
   "node_modules/@vmw/transport/transport.umd.min.js"
]
...

Your application is ready to go, now you just need to boot transport

Angular provides a src/main.ts file, which is essentially your initialization script, that you can use to Initialize the Bus. See Option 1 above for instructions on initializing the bus.

Option 3: UMD module import through HTML <script> tag

Alternatively if you would like to use Transport in a simple setup, say an HTML with WebComponents in it, you can import the UMD version of the library via a script tag. Note that RxJS is the only prerequisite for Transport so make sure to import it first.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/bundles/rxjs.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@vmw/transport@latest/transport.umd.min.js"></script>
<script>
   // boot the event bus!
   transport.TransportEventBus.boot();

   // once booted you can access the event bus instance at window.AppEventBus.
   console.log(AppEventBus);

   // destroy the event bus.
   transport.TransportEventBus.destroy();

   // boot the event bus with options.
   transport.TransportEventBus.bootWithOptions(1, false, true);

</script>

Importing Transport in your code

The main interface you will need is EventBus. It provides access to the most common methods.

import { EventBus } from '@vmw/transport';

Hello World

export class HelloWorldComponent extends AbstractBase implements OnInit {

    constructor() {
        super('HelloWorldComponent');
        this.run();
    }

    run() {

        // define a channel to talk on.
        let myChannel = 'some-channel';

        // listen for requests on 'myChannel' and return a response.
        this.bus.respondOnce(myChannel)
            .generate(
                (request: string) => {
                    this.log.info(`Request Received: ${request}, Sending Response...`);
                    return 'world';
                }
            );

        this.log.info('Sending Request');

        // send request 'hello' on channel 'myChannel'.
        this.bus.requestOnce(myChannel, 'hello')
            .handle(
                (response: string) => {
                    this.log.info(`hello ${response}`);
                }
            );
    }
}

Read More TypeScript Documentation

Contributing

The transport-typescript project team welcomes contributions from the community. Before you start working with transport-typescript, please read our Developer Certificate of Origin. All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. For more detailed information, refer to CONTRIBUTING.md.

License

BSD-2-Clause

Copyright (c) 2017-2021, VMware, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.