Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kapilkaisare/daemonizejs

A non jQuery version of my daemonizer plugin
https://github.com/kapilkaisare/daemonizejs

Last synced: 9 days ago
JSON representation

A non jQuery version of my daemonizer plugin

Awesome Lists containing this project

README

        

daemonizejs
===========

Daemonize is a tool that takes a method and returns a function with a daemon like interface (start, stop, restart).

Usage
-----

var testFun = function () {
// Do something
};

var daemon = $.daemonize(testFun, 1000);

daemon.start(); // will run the testFun every second.
daemon.stop(); // will stop the testFun from running.
daemon.restart(); // will stop, then start the function.

You can also specify a function that runs on the restart invocation once the daemon stops.

var reinit = function () {
// Clean up
};

var daemon2 = $.daemonize(testFun, 1000, reinit);

daemon2.start();
daemon2.restart(); // stops testFun, runs reinit, then starts testFun again