asyncworkflow
Simple library that allows you to run async promise based code as if you were writing synchronous code.
How to use
If you are using es6 then simpoy import the library and call it.
import asyncLib from 'asyncworkflow'
asyncLib.runAsyncWorkflow( ## YOUR GENERATOR FUNCTION ## )();
Please note that your comsuming app will require babel-polyfill.
Typical Scenarios
You can use this library when youu don't want to get caught up in the .then chain hell that can happen within promises.
Example
Write your generator that has aync (promise based code) and sync code lines:
let myGenerator = function*() {
let result1 = yield axios.get('some http call');
let result2 = doSynchronousCall(result1);
let result3 = yield callAnotherAsyncPromiseBasedThing(result2);
return result3;
};
asyncLib.runAsyncWorkflow(myGenerator)();
Notes
You can run my library directly within your ES6 project by lifting the file 'index_src.js' from within the 'src' folder.