All Projects → voryx → thruway.js

voryx / thruway.js

Licence: MIT license
RxJS WAMPv2 Client

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to thruway.js

Rx.wamp
An RX wrapper library for Wamp in the browser and node
Stars: ✭ 37 (+32.14%)
Mutual labels:  rxjs, wamp, realtime-messaging
accelerator-textchat-ios
OpenTok Text Chat Accelerator Pack enables text messages between mobile or browser-based devices.
Stars: ✭ 13 (-53.57%)
Mutual labels:  realtime-messaging
React Streams
Stars: ✭ 226 (+707.14%)
Mutual labels:  rxjs
ts-action-operators
TypeScript action operators for NgRx and redux-observable
Stars: ✭ 34 (+21.43%)
Mutual labels:  rxjs
Blog Angular
Angular 笔记
Stars: ✭ 238 (+750%)
Mutual labels:  rxjs
Android-MQTT-Demo
An android application to demonstrate the complete MQTT lifecycle.
Stars: ✭ 31 (+10.71%)
Mutual labels:  realtime-messaging
Rxjs Ultimate Cn
RxJS Ultimate 中文版
Stars: ✭ 219 (+682.14%)
Mutual labels:  rxjs
learnrxjs
Русскоязычная документация RxJS
Stars: ✭ 20 (-28.57%)
Mutual labels:  rxjs
vuse-rx
Vue 3 + rxjs = ❤
Stars: ✭ 52 (+85.71%)
Mutual labels:  rxjs
Rxdb
🔄 A client side, offline-first, reactive database for JavaScript Applications
Stars: ✭ 16,670 (+59435.71%)
Mutual labels:  rxjs
Rxjs Websockets
A very flexible and simple websocket library for rxjs
Stars: ✭ 248 (+785.71%)
Mutual labels:  rxjs
Stuhome
📱 An iOS client for https://bbs.uestc.edu.cn/ written in react-native, redux and redux-observable.
Stars: ✭ 241 (+760.71%)
Mutual labels:  rxjs
rdeco
响应式对象编程库,从时间和空间上解耦你的代码
Stars: ✭ 54 (+92.86%)
Mutual labels:  rxjs
Api
Promise and RxJS APIs around Polkadot and any Substrate-based chain RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata. Full documentation & examples available
Stars: ✭ 232 (+728.57%)
Mutual labels:  rxjs
react-nonav
Experimental React Native declarative navigation
Stars: ✭ 58 (+107.14%)
Mutual labels:  rxjs
Angular Ru Interview Questions
Вопросы на собеседовании по Angular
Stars: ✭ 224 (+700%)
Mutual labels:  rxjs
Angularfire Lite
⚡️ Lightweight library to use Firebase API 🔥 with Angular
Stars: ✭ 245 (+775%)
Mutual labels:  rxjs
rxremote
Subscribe to RxJs Observables on a remote server through a WebSocket
Stars: ✭ 27 (-3.57%)
Mutual labels:  rxjs
observable-profiler
Tracks new & disposed Observable subscriptions
Stars: ✭ 41 (+46.43%)
Mutual labels:  rxjs
streamr-client-javascript
JS library for interacting with Streamr APIs: publishing and subscribing to data, creating streams, etc.
Stars: ✭ 35 (+25%)
Mutual labels:  realtime-messaging

Build Status

Thruway.js

This project is a WAMP v2 client written in TypeScript that uses RxJS v5 Observables instead of promises and event emitters. It's designed to work with modern frontend frameworks like Angular v2/4 as well as node.js.

If you don't know what WAMP is, you should read up on it.

If you don't know what RxJS or ReactiveExtensions is, you're missing out...

note: This library is stable, but may not have all of the WAMP features implemented. Since this project originated as an internal project for Voryx, the features are limited to only the ones that were needed.

Installation

npm install thruway.js
npm install rxjs
npm install ws // only when using with Node

Usage

import {Client} from "thruway.js";

const wamp = new Client('ws://localhost:9090', 'realm1');

Call

wamp.call('add.rpc', [1, 2])
    .map((r: ResultMessage) => r.args[0])
    .subscribe(r => console.log(r));

Register

wamp.register('add.rpc', (a, b) => a + b).subscribe();

If you need keyword arguments, you can set the extended option.

wamp.register('add.rpc', (args, argskw) => argskw.a + argskw.b, {extended: true}).subscribe();

Publish to topic

wamp.publish('example.topic', 'some value');
wamp.publish('example.topic', Observable.interval(1000)); // you can also publish an observable

Subscribe to topic

wamp.topic('example.topic').subscribe((v)=>console.log(v));

Angular Example

Create a wamp service

import {Injectable} from '@angular/core';
import {Client} from 'thruway.js';

@Injectable()
export class WampService extends Client {
    constructor() {
        super('wss://demo.crossbar.io/ws', 'realm1');
    }
}

Inject and use the service in your component

import {Component} from '@angular/core';
import {WampService} from '../wamp.service';
import {Observable} from 'rxjs/Observable';
import {EventMessage} from 'thruway.js/src/Messages/EventMessage';

@Component({
    selector: 'app-counter',
    template: '<span>{{counter | async}}</span>'
})
export class CounterComponent {
    counter: Observable<number> = this.wamp
        .topic('com.myapp.counter')
        .map((r: EventMessage) => r.args[0]);

    constructor(private wamp: WampService) {}
}

Node Example

const Thruway = require("thruway.js");
const Rx = require("rxjs");

const wamp = new Thruway.Client('wss://demo.crossbar.io/ws', 'realm1');

wamp.publish('com.myapp.counter', Rx.Observable.interval(1000));

PHP Example

Install the RxThruway Client

composer require rx/thruway-client
<?php

use Rx\Observable;
use Rx\Thruway\Client;

require __DIR__ . '/vendor/autoload.php';

$wamp = new Client('wss://demo.crossbar.io/ws', 'realm1');

$wamp->publish('com.myapp.counter', Observable::interval(1000));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].