My issue with promises is that I find myself working around the API/language when I actually want synchronous code. My app calls a JSON API and then writes the results to three tables (in sequence). In "normal", blocking code:
results = getResults(); writeTable1(results.foo); writeTable2(results.bar); writeTable3(results.baz);
Using Node and Q: db.load().then(()-> setupDB(db)).then(()-> collectData(db)).done()
In which setupDB() returns a chain of three promises and collectData, which loops through the results and attach a new promise to the chain in order to return a chain of `n` promises.Are these just growing pains of learning a new paradigm or am I using the wrong tool for the job?
Can someone point me to any projects that actually use promises?