activity

Activity Manager for any kind of statuses based on ids

npm install activity
4 downloads in the last week
10 downloads in the last month

Activity Build Status Coverage Status NPM version

Activity Manager for any kind of statuses based on ids

Getting Started

npm install activity --save-dev

Create an activity

var Activity = require('activity');

var activity = new Activity({
  statuses: ["online", "offline", "away"]
});

Set an status

activity.setStatus('uid1', 'online', function(err){
  if (err) {
    // somthing went wrong
  }
});

// you can set an status without checking if it was applied
activity.setStatus('uid2', 'away');
activity.setStatus('uid3', 'online');

Get statuses

activity.getStatus(['uid1', 'uid2'], function(err, statuses){
  if (err) {
    // somthing went wrong
  }
  else {
    console.dir(statuses); // { uid1: 'online', uid2: 'away' }
  }
});

Get one status

activity.getStatus('uid1', function(err, status){
  if (err) {
    // somthing went wrong
  }
  else {
    console.dir(status); // 'online'
  }
});

Get ids by an status

activity.getIds('online', function(err, ids){
  if (err) {
    // somthing went wrong
  }
  else {
    console.dir(ids); // [ 'uid1', 'uid3' ]
  }
});

TODO

  • Add option to use Redis to store the current statuses.
  • A way to clear all ids.

Contribute

  1. Fork this repo
  2. run npm install
  3. Create the tests for the new functionality or bug case
  4. Put your awesome code
  5. run grunt test
  6. All good?, place a pull request
npm loves you