firehose-client
Firehose is both a Rack application and JavaScript library that makes building real-time web applications possible.
Last updated a year ago by geeks .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install firehose-client 
SYNC missed versions from official npm registry.
  __ _          _
 / _(_)        | |
| |_ _ _ __ ___| |__   ___  ___  ___
|  _| | '__/ _ \ '_ \ / _ \/ __|/ _ \
| | | | | |  __/ | | | (_) \__ \  __/
|_| |_|_|  \___|_| |_|\___/|___/\___|

Javascript client

Build Status Code Climate Test Coverage

What is Firehose?

Firehose is both a Rack application and JavaScript library that makes building real-time web applications possible.

Usage

Node

$ npm install firehose-client

// Register browser globals
> require("firehose-client/register")

// Access the classes
> Firehose = require("firehose-client")

Browser

Serve /dist/firehose.vendor.js and /dist/firehose.js then you will be able to access the window.Firehose object.

The JavaScript Consumer


new Firehose.Consumer({
  message: function(msg){
    console.log(msg);
  },
  connected: function(){
    console.log("Great Scotts!! We're connected!");
  },
  disconnected: function(){
    console.log("Well shucks, we're not connected anymore");
  },
  error: function(){
    console.log("Well then, something went horribly wrong.");
  },
  // Note that we do NOT specify a protocol here because we don't
  // know that yet.
  uri: '//localhost:7474/hello'
}).connect();

There's also a Consumer that uses channel multiplexing. The multiplexed consumer is useful for scenarios where you want to subscribe to messages from many channels at once, without having to use one connection per channel. You can specify a list of channels to subscribe to, including a handler function per channel that gets called with all messages coming from that channel.

Example:

new Firehose.MultiplexedConsumer({
  connected: function(){
    console.log("Great Scotts!! We're connected!");
  },
  disconnected: function(){
    console.log("Well shucks, we're not connected anymore");
  },
  error: function(){
    console.log("Well then, something went horribly wrong.");
  },
  // Note that we don't specify a general message handler function
  // but instead define one per channel below

  // Note that we do NOT specify a protocol here because we don't
  // know that yet. We also don't specify a specific channel name as part of
  // the URI but instead pass in a list of subscriptions below
  uri: '//localhost:7474/',

  // List of channel subscriptions:
  channels: {
    "/my/channel/1": {
      last_sequence: 10,        // defaults to 0 and can be ommitted
      message: function(msg) {
        console.log("got message on channel 1:");
        console.log(msg);
      }
    },
    "/my/channel/2": {
      message: function(msg) {
        console.log("got message on channel 2:");
        console.log(msg);
      }
    }
  }
}).connect();

Then publish another message.

$ curl -X PUT -d "\"This is almost magical\"" "http://localhost:7474/hello"

Current Tags

  • 1.4.2-beta.1                                ...           beta (a year ago)
  • 1.4.6                                ...           error-handling (a year ago)
  • 1.4.11                                ...           latest (a year ago)
  • 1.2.1-webpack-rc2                                ...           webpack (2 years ago)
  • 1.2.1-webpackv3-rc1                                ...           webpackv3 (2 years ago)

28 Versions

  • 1.4.11                                ...           a year ago
  • 1.4.10                                ...           a year ago
  • 1.4.8                                ...           a year ago
  • 1.4.7                                ...           a year ago
  • 1.4.6                                ...           a year ago
  • 1.4.5                                ...           a year ago
  • 1.4.4                                ...           a year ago
  • 1.4.3                                ...           a year ago
  • 1.4.2-beta.1                                ...           a year ago
  • 1.4.2-beta.0                                ...           2 years ago
  • 1.4.2                                ...           2 years ago
  • 1.4.1                                ...           2 years ago
  • 1.4.0                                ...           2 years ago
  • 1.3.1                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.1-webpackv3-rc1                                ...           2 years ago
  • 1.2.1-webpack-rc2                                ...           2 years ago
  • 1.2.1-webpack-rc1                                ...           2 years ago
  • 1.2.1                                ...           2 years ago
  • 1.2.0-webpackv3-rc3                                ...           2 years ago
  • 1.2.0-webpackv3-rc2 [deprecated]           ...           3 years ago
  • 1.2.0-webpackv3-rc1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (16)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |