1.2.4 • Published 8 years ago

rockets v1.2.4

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Rockets Author Version Dependencies


This is a client for rockets/rockets.

Demo

See rockets/demo.

Installation

npm install rockets

Usage

var Rockets = require('rockets');

var client = new Rockets();

// Register events on the client.
client.on('connect', function() {

  var include = {

    // Only receive comments in r/programming.
    subreddit: 'programming',

    // Only receive comments that contain the pattern 'rockets'.
    contains: [
      'rockets',
    ]
  };

  var exclude = {

    // Skip comments that contain the word "hack".
    contains: [
      'hack',
    ]
  };

  // Subscribe to the 'comments' channel.
  client.subscribe('comments', include, exclude);
});

client.on('comment', function(comment) {
  // Do something using the comment data.
});

// Initiate the client's socket connection.
client.connect();

Events

Events can be registered with client.on('event', handler).

EventArgumentsDescription
connectConnection to the server has been established
disconnectConnection to the server has been lost
errorerrorError has occurred
modelmodelReceived model, either post or comment
commentmodelReceived a comment
postmodelReceived a post

Functions

NameArgumentsDescription
subscribechannel, [include , exclude]Subscribes to a channel, with optional include and exclude rules
availableReturns true if the socket connection is open
closeClose the connection to the server

Credits

Illustrations by Ken Samonte.

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.1

12 years ago

0.1.0

12 years ago