Skip to content

Commit

Permalink
expanding for use outside hive-mvc.
Browse files Browse the repository at this point in the history
  • Loading branch information
bingomanatee committed Oct 18, 2013
1 parent e2a64ae commit db37cd5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,26 @@ More complex intervals can be expressed as a function that recievs the time as

The cronomter mixin fires off at -1000... (very negative number) so other mixins can use it.

## Installing Chronometer
## Installing Chronometer in hive-mvc

put the chronometer file in any resources/mixins folder.
you should not have more than one chronometer in a hive-mvc project;
it is written to only install itself
if there is not a chronometer in the apiary's config already.

## Using Chronomter outside of hive-mvc.

the export of chronometer is a function for use in hive-mvc; however it does have a Chronometer constructor as a property so
you can just call;

``` javascript
var my_sandbox = {};
var my_chron = new (require('./chronometer.js'))Chronometer(my_sandbox);

```

The single argument to Chronometer(Chron_Manager) isn't used any way by Chronometer.

## Example mixin using Chronometer:

``` javascript
Expand Down Expand Up @@ -80,4 +93,19 @@ that the manager emits.
## The last of the timelords

The manager's clock can be started and stopped; you can call `manager.stop_clock()` or `manager.start_clock`.
This is useful for unit tests or other scenarios where you want to control the execution of long tasks.
This is useful for unit tests or other scenarios where you want to control the execution of long tasks.

You could, for instnace, stop the clock and fire off times at whatever interval you please -- every five minutes,
every 15 minutes, every hour....

## Why this doesn't use/emulate CHRON

I find the notation of Chron overly arcane. I figured its best to just handle the "Extreme" scenarios:

1. You want to do something on a regular interval (pretty common)
2. You want to do something on a strange interval (for which you can write a function).

Giving you a function that interprets an absolute time really frees you up. You can execute on a given set of
absolute dates, or even pull a set of times from a data feed and execute on those times.

If the Chron system of notation works for you, using node-chron is pretty easy, and chronometer is not the module for you.
4 changes: 3 additions & 1 deletion chronometer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,6 @@ module.exports = function (apiary, cb) {
done();
}
}); // end callback
}
};

module.exports.Chronomter = Chron_Manager;
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "chronometer",
"privtae": true,
"version": "0.0.1",
"description": "a hive-mvc mixin to fire off events at given intervals",
"main": "chronometer.js",
Expand Down

0 comments on commit db37cd5

Please sign in to comment.