pull(
queue,
pullParaMap((continuable, done) => continuable(done), 10),
pull.drain()
)
// My vuex action that was getting hammered
// actions here play well with Promises
async function getPersonMinimal (_, profileId) {
// make a Promise (so we can return some thing)
return new Promise((resolve, reject) => {
// set a our query *ready* to be run
const runQuery = async (done) => {
try {
const res = await apollo.query(getPersonMinimal(profileId))
if (res.errors) throw res.errors
resolve(res.data.person)
} catch (err) {
reject(err)
}
done()
}
// stick this in the queue of things to run,
// along with the resolve / reject for handling the results
queue.push(runQuery)
})
}
oh it's exquisite now @Nico [ Perihelion ]
I knew this pattern felt familiar : https://github.com/Raynos/continuable . This is a trippy data flow to get your head around aye.