From 4bd1b950018eda2d215e7db540c0d5967e7dfb65 Mon Sep 17 00:00:00 2001 From: Philip Tellis Date: Thu, 6 Sep 2012 12:31:31 -0400 Subject: [PATCH 1/2] Rename README to README.md github will render markdown documents as HTML, which gives us prettier fonts, better headings and the ability to do syntax highlighting for code. This makes the README easier to read on github. --- README => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.md (100%) diff --git a/README b/README.md similarity index 100% rename from README rename to README.md From 8bb3e33b1fc3766df8690a6214d22a4d53e30c2e Mon Sep 17 00:00:00 2001 From: Philip Tellis Date: Thu, 6 Sep 2012 12:32:22 -0400 Subject: [PATCH 2/2] Reformat README for markdown Reformat the README document to take advantage of Markdown formatting. This can be easily converted to different formats including HTML and man pages. Also syntax highlight all code with appropriate language markers. --- README.md | 114 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 623bad0..60a45d6 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,71 @@ Created to simplify flow management when programming in asynchronous environments like nodejs. - CauseEffect extends EventEmitter and allows to set cause-effect scenarios. - - It is simple yet effective. - - CauseEffect allows you to: - * have an event fired when multiple parallel flows complete. - * easily unite multiple parallel flows initiated from the for loop. - * set up chains: completion of one rule may trigger another. - * set the rules dynamically or statically. - * have an event fired when any of the flows completes. - - To run example: - node examples/sample.js - -Installation: - npm install causeeffect - -Usage: - To setup a rule where an event will fire if all of the causes happen: - ce.setEvents("myevent", ["cause1", "cause2", "cause3"]); - - To setup a rule where an event will fire if some of the causes happen: - ce.setEvents("myevent", ["cause1", "cause2", "cause3"], true); - - To setup a rule where an event will fire if it happens X times: - ce.setEvents("myevent", 10); - - Listen to effect event as usual with EventEmitter API: - ce.on("myevent", callback); - - To let CauseEffect know that the cause has happened call: - ce.setState("cause1"); - or if you need a specific value use - ce.setState("cause1", value); - This value can be then obtained from your event callback with: - ce.getState("cause1") - - To run example: - node examples/sample.js - -Sample: - -1. Uniting multiple parallel flows initiated from the for loop: +CauseEffect extends EventEmitter and allows to set cause-effect scenarios. + +It is simple yet effective. + +CauseEffect allows you to: +* have an event fired when multiple parallel flows complete. +* easily unite multiple parallel flows initiated from the for loop. +* set up chains: completion of one rule may trigger another. +* set the rules dynamically or statically. +* have an event fired when any of the flows completes. + +## To run example: +``` +node examples/sample.js +``` + +## Installation: +``` +npm install causeeffect +``` + +## Usage: +To setup a rule where an event will fire if all of the causes happen: +``` javascript +ce.setEvents("myevent", ["cause1", "cause2", "cause3"]); +``` + +To setup a rule where an event will fire if some of the causes happen: +``` javascript +ce.setEvents("myevent", ["cause1", "cause2", "cause3"], true); +``` + +To setup a rule where an event will fire if it happens X times: +``` javascript +ce.setEvents("myevent", 10); +``` + +Listen to effect event as usual with EventEmitter API: +``` javascript +ce.on("myevent", callback); +``` + +To let CauseEffect know that the cause has happened call: +``` javascript +ce.setState("cause1"); +``` +or if you need a specific value use +``` javascript +ce.setState("cause1", value); +``` +This value can be then obtained from your event callback with: +``` javascript +ce.getState("cause1") +``` + +To run example: +``` +node examples/sample.js +``` + +## Sample: + +1. Uniting multiple parallel flows initiated from the for loop: + + ``` javascript var ce = require('causeeffect'); ce = new ce.CauseEffect(); @@ -61,9 +83,11 @@ Sample: ce.on("myticker", function() { }); + ``` +2. Uniting specific parallel flows -2. Uniting specific parallel flows + ``` javascript // Set up AND cause effect. Event "alldone" will be fired if all of causes happen ce.setEvents("alldone", ["cause1", "cause2", "myticker"]); @@ -75,5 +99,5 @@ Sample: // To let CauseEffect know that the cause has happened ce.setState("cause1"); ce.setState("cause2"); - + ```