Show notes
Hey friends so I got a question on discord from somebody who asked
effectively is it okay to put async away on a function that doesn't need itand you can get useless rules that will prevent this. I think I have theenabled because I don't typically want to do this but there are situationssometimes where you want to start with an API that isn't asynchronous nowbut you're pretty confident that it's going to be asynchronous in thefuture and it's just easier.To plan with that asynchrony from the get-go rather than try to retrofit
everything to work with asynchrony in the future and so yes, it's I thinkit's acceptable and it's okay to make something async when it doesn't needto be and you just have to be aware that any consumer is going to have toconsume an async API rather than a synchronous one and you'll have toconsider the fact that because it's async it it is like as soon as youattach that async keyword onto the function onto the function keyword likeright in front of that function keyword or in front of theParentheses ifyou're doing an arrow function whatever as soon as you put that asynckeyword on there it immediately means that no matter what the function doesit's returning a promise and the any consuming code cannot proceed untilthe next tick of the event loop, you know, I'm talking about like if theconsuming code is using async away if it's using promises with dot thenthen the the success handler of that promise is going to run on the nexttick of the event loop and so that means that just has some interestingimplications around you know closures andStillness and but in in practicethat's not normally going to be too much of an issue so I would say thatyeah it's okay to put async on a function that doesn't need it but Iwouldn't do it for no reason so like there would need to be an explanationand in a code base where you have coworkers who are going to look at thiscode and and even yourself who's going to look at this code in the future,it would be useful for you to write a code comment to explain why you'redoing this so that people don't remove it and then accidentally break someconsuming code because you're not using type script, for example.If you're using textcript then you know, maybe it's okay, but anyway, I
hope that is useful to you and I hope that you had a marvelous day in thator that you're going to whenever this is, you know, good afternoon goodevening tonight. Truman shows now and I'll talk to you later bye.
