Closed samjewell closed 8 years ago
ps. I can submit a PR, just let me know which of the above things you'd prefer. Upon reflection probably the very last suggestion right?
@samjewell I'm not sure your example will work, as the thenRunThisFunction
will be invoked before the asynchronous waitAMinute
callback is called.
If you are still stuck on this (which I doubt as it's been over a year :dizzy_face:), please open a PR. Thanks!
what would you say to renaming waitAMinute
to waitAMinuteAsync
? For extra clarity...
The fact that one of waitAMinute
's arguments is a function is a clear indication that it's an asynchronous function. But if you think changing the name makes it more clear, please send a PR and I'll have a look.
I think that for us, developers - this is clear that this function will be an async one. But if we want to clarify everything related with javascript callback functions, their (people who are learning from this repo) brains are already melting with that amount of information. We need to treat them (without insulting!) like kids who are learning alphabet. Everything just must be big and bold ;)
The fact that one of waitAMinute's arguments is a function is a clear indication that it's an asynchronous function
Is it? Couldn't I have a function that takes another function as an argument, but operates synchronously? I'm sure some lodash functions do that. Eve if they don't I could write one, surely?
Agreed to someone who has some experience with JS this 'looks like' an async function, but the only way to find out for sure is to try it out / look at the sourcecode / docs, isn't it? Or am I wrong somewhere?
Function renamed here: https://github.com/maxogden/art-of-node/pull/65
I feel like this is much more complicated than the concrete callbacks example we've just encountered.
Shouldn't
thenRunThisFunction()
be called one line further down, as shown below, for true reflection of the concrete example before this part?But then, is waitedAMinute even invoked at any point at all? This would make much more sense to me:
Of if the point is that
waitAMinute()
is async, whilewaitedAMinute
is either sync, or a cb, then can we name them that way? eg.waitAMnuteAsync()
andwaitedAMinuteCallback()