Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

rockets/client

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

Event Arguments Description
connect Connection to the server has been established
disconnect Connection to the server has been lost
error error Error has occurred
model model Received model, either post or comment
comment model Received a comment
post model Received a post

Functions

Name Arguments Description
subscribe channel, [include [, exclude]] Subscribes to a channel, with optional include and exclude rules
available Returns true if the socket connection is open
close Close the connection to the server

Credits

Illustrations by Ken Samonte.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.