0.1.1 • Published 11 years ago
activity v0.1.1
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
- Fork this repo
- run
npm install
- Create the tests for the new functionality or bug case
- Put your awesome code
- run
grunt test
- All good?, place a pull request