I am programminfg in node.js
sometimes async functions become really incredibly dirty. I want to write async code but retrieve data as an event happens i am aware of promises but it is not exactly what i want simply what i ask is something like this
asyncFunc(error,dt,ld){
//some async code such as db operations
}
then i want to fetchj the data in event way
asyncFunc.on("dt",function(dt){do something});
asyncFunc.on("error",function(err){i have an error object});
asyncFunc.on("ld",function(ls){loading});
is there any way to do this i know promises and some 3rd party libraries against callback hell but my question is especially in that way i wrote how i can design my code ?
Aucun commentaire:
Enregistrer un commentaire