flowa
Advanced tools
Comparing version 4.0.1 to 4.0.2
{ | ||
"name": "flowa", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "Service level control flow for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,2 +13,4 @@ <p align="center"><img src="/logo.png?raw=true" alt="Flowa Logo"/></p> | ||
One execution flow that runs mixed sync and async functions that uses either promises or callbacks running in parallel, sequentially or mixed. 🔥 **It can't be easier and more readable !** | ||
# Hint | ||
@@ -59,3 +61,3 @@ | ||
Each `flow` is a set of `tasks`. It starts by a `compound task` which is basically a task that groups a set of `single tasks`. Single tasks are async functions that are executed and called by passing an object called `context` to allow sharing data between tasks and a `callback` function. Each compound task's sub tasks are executed by a `runner` that can be a `serial` execution (default type) or a `parallel` execution. | ||
Each `flow` is a set of `tasks`. It starts by a `compound task` which is basically a task that groups a set of `single` or other `compound` tasks. Single tasks are either async or sync functions that are executed and called by passing an object called `context` to allow sharing data between tasks and an optional `callback` function for async tasks that use callbacks instead of promises. Each compound task's sub tasks are executed by a `runner` that can be a `serial` execution (default type) or a `parallel` execution. | ||
@@ -70,3 +72,3 @@ ## Installation | ||
We need to create a new Flowa object with our flow using `new Flowa(flow[, name])` or `Flowa.create(flow[, name])`. | ||
We need to create a new Flowa object with our flow using `new Flowa(flow[, name])`, `Flowa.create(flow[, name])`, or just use the [Shorthand Method](#shorthand-method) it is much easier and recommended if you are not planning to execute the same flow again and again. | ||
@@ -83,9 +85,9 @@ ```js | ||
// A task that uses a callback | ||
task1: task1, | ||
asyncTaskWithCallback: asyncTaskWithCallback, | ||
// A task that returns a promise | ||
task2: task2, | ||
asyncTaskWithPromise: asyncTaskWithPromise, | ||
// A sync task | ||
task3: task3 | ||
syncTask: syncTask | ||
@@ -117,5 +119,4 @@ }); | ||
// A task that uses a callback | ||
function task1(context, callback) { | ||
function asyncTaskWithCallback(context, callback) { | ||
console.log('Executing task 1'); | ||
setTimeout(callback.bind(null, null, 'DummyValue1'), 500); | ||
@@ -126,6 +127,4 @@ | ||
// A task that returns a promise | ||
function task2(context) { | ||
function asyncTaskWithPromise(context) { | ||
console.log('Executing task 2'); | ||
context.extraDummyValue2 = 'extraDummyValue2'; | ||
return Promise.resolve('DummyValue2'); | ||
@@ -136,5 +135,4 @@ | ||
// A sync task | ||
function task3(context) { | ||
function syncTask(context) { | ||
console.log('Executing task 3'); | ||
return 'DummyValue3'; | ||
@@ -240,3 +238,3 @@ | ||
You can use sync tasks that doesn't return a promise and doesn't take a second callback argument. The callbacks will be called internally. | ||
You can use sync tasks that doesn't return a promise and doesn't take a second callback argument. | ||
@@ -475,11 +473,8 @@ ```js | ||
* | ||
* @param {Object} context | ||
* @param {Function} callback | ||
* @param {Object} context | ||
*/ | ||
function incrementGreetingCounter(context, callback) { | ||
function incrementGreetingCounter(context) { | ||
context.counterValue = ++counter; | ||
callback(); | ||
} | ||
@@ -490,6 +485,5 @@ | ||
* | ||
* @param {Object} context | ||
* @param {Function} callback | ||
* @param {Object} context | ||
*/ | ||
function generateGreetingMessage(context, callback) { | ||
function generateGreetingMessage(context) { | ||
@@ -501,4 +495,2 @@ context.res.send({ | ||
callback(); | ||
} | ||
@@ -505,0 +497,0 @@ |
247762
617