2.0.1 • Published 10 years ago

tasks-subscribe v2.0.1

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

Tasks Subscribe

NPM VersionNode VersionBuild StatusCode Climate

Task Manager with Subscribers for node.

Installation

$ npm install tasks-subscribe

Example

var TaskManager = require('tasks-subscribe');

var userId = 1; // user id, will be subscribed at the start

var output = [];

// Get TaskManager Environment By UserID
// And create task with some calculations
var task = TaskManager(userId).addTask(function(){

	this.trigger('test', {hello: 'hello world!'}); // trigger test event

	this.done();

}).settings({

	some: 'task',
	name: 'Task Example'

}).on('done', function(){

	output.push(['completed', this.get('some')]); // completed task

	output.push(['users subscribed on done', this.getSubscribers()]); // get subscribers at end

}).on('test',function(context){

	output.push([context.hello]); // hello world!

	output.push(['users subscribed at test event', this.getSubscribers()]); // get subscribers at any event

});

task.start(); // Run task

TaskManager().on('done', function(){

	console.log(output);

});

/*
[ [ 'hello world!' ],
  [ 'users subscribed at test event', [ 1, 3 ] ],
  [ 'completed', 'task' ],
  [ 'users subscribed on done', [ 1, 3 ] ] ]
*/

task.subscribe(3);
  1. First Local Events
  2. Second Global Events

License

MIT

2.0.1

10 years ago

2.0.0

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago